| | |
When Can I Use FSO FileSystemObject
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
When can you use FSO in a VB 5 program?
I got it working... I know it is supposed to be for ASP...
But why does it work in some applications ans situations and not others.?
Here is the code
Private fso As New FileSystemObject
Private strName As String
Private Sub Command1_Click()
With fso
strName = .BuildPath(Text2.Text, Text3.Text)
Set strm = .CreateTextFile(strName, True)
strm.Write (Text1.Text)
End With
MsgBox "text saved"
Exit Sub
a:
MsgBox "an error has occurd"
End Sub
Private Sub Command2_Click()
' Text1 is used to display the text file
' Text 2 is the Drive
' Text 3 is the Filename...
On Error GoTo a
With fso
strName = Text2.Text & "\" & Text3.Text
Set strm = .OpenTextFile(strName, ForReading)
With strm
Do Until .AtEndOfStream
Text1.Text = Text1.Text & .ReadLine & vbCrLf
Loop
End With
End With
Exit Sub
a:
MsgBox "an error has occurd"
End Sub
I got it working... I know it is supposed to be for ASP...
But why does it work in some applications ans situations and not others.?
Here is the code
Private fso As New FileSystemObject
Private strName As String
Private Sub Command1_Click()
With fso
strName = .BuildPath(Text2.Text, Text3.Text)
Set strm = .CreateTextFile(strName, True)
strm.Write (Text1.Text)
End With
MsgBox "text saved"
Exit Sub
a:
MsgBox "an error has occurd"
End Sub
Private Sub Command2_Click()
' Text1 is used to display the text file
' Text 2 is the Drive
' Text 3 is the Filename...
On Error GoTo a
With fso
strName = Text2.Text & "\" & Text3.Text
Set strm = .OpenTextFile(strName, ForReading)
With strm
Do Until .AtEndOfStream
Text1.Text = Text1.Text & .ReadLine & vbCrLf
Loop
End With
End With
Exit Sub
a:
MsgBox "an error has occurd"
End Sub
![]() |
Similar Threads
- Optimizing text file writing in VB 6.0 (Visual Basic 4 / 5 / 6)
- Run-Time error 5 (Visual Basic 4 / 5 / 6)
- Code for Call the program in Visual Basic (Visual Basic 4 / 5 / 6)
- FileSearch and replace (Visual Basic 4 / 5 / 6)
- FSO problem (ASP)
- RmDir and MsChart Have Problems in XP -Pls Help (Visual Basic 4 / 5 / 6)
- help with windows server logon script (Windows NT / 2000 / XP)
- Problem Downloading large files (ASP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Connect server with VB 6.0
- Next Thread: Stopping a timer
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





