File System + File I/O in VB6: Difference between revisions
Jump to navigation
Jump to search
New page: == Write/Create a new file using FileSystemObject == *must add 'reference' to "Microsoft Scripting Runtime" Dim fso As New FileSystemObject, fsoStream As TextStream Dim rec1, strLine... |
No edit summary |
||
| Line 30: | Line 30: | ||
| | ||
== Launch Another Program (any) From Your VB Program == | |||
Private Sub launchSLXAssist() | |||
Dim intExecute% | |||
If InStr(LCase(Command), "/interpreter") > 0 Then | |||
MsgBox "Shell SLXAssist.exe" | |||
Else | |||
intExecute% = Shell("SLXAssist.exe /verified", 1) | |||
End If | |||
End Sub | |||
| |||
== Check if Network Path and File are available == | |||
Private Sub checkFile01() | |||
' [step 1]: check to see if the network path and autoupdate.xml are available | |||
Dim fLen As Integer | |||
Dim strResponse% | |||
tmr.Enabled = False | |||
intbarProg = 0: barProg.Value = intbarProg | |||
On Error Resume Next | |||
fLen = Len(Dir$(xmlfilepath)) | |||
strResponse% = vbRetry | |||
While strResponse% = vbRetry | |||
If Err Or fLen = 0 Then | |||
' file dosent exist | |||
strResponse% = MsgBox("Error: XML inaccessible for auto-update!", vbAbortRetryIgnore, "SALESLOGIX ASSISTANT") | |||
Else | |||
' file exists | |||
strResponse% = 0 | |||
End If | |||
Wend | |||
On Error GoTo 0 | |||
End Sub | |||
| | ||
Revision as of 09:09, 2 February 2008
Write/Create a new file using FileSystemObject
- must add 'reference' to "Microsoft Scripting Runtime"
Dim fso As New FileSystemObject, fsoStream As TextStream
Dim rec1, strLine, strFileSpec
Dim cnt0 As Integer, tag1 As Integer
strFileSpec = Environ("HOMEPATH") & "\My Documents\kaching.log"
strLine = "kaching incident " & Date & " " & Format(time, "HH:mm:ss") & vbCrLf
Set fsoStream = fso.CreateTextFile(strFileSpec, True)
fsoStream.Write strLine
fsoStream.Close
Set fsoStream = Nothing: Set fso = Nothing
Write if exists, create if doesn't exist using FileSystemObject
If fso.FileExists(strFileSpec) Then Set fsoStream = fso.OpenTextFile(strFileSpec, 2) Else Set fsoStream = fso.CreateTextFile(strFileSpec, True) End If fsoStream.Write strLine fsoStream.Close Set fsoStream = Nothing: Set fso = Nothing
' strFileSpec, 1 : ForReading 2 : ForWriting 8 : ForAppending
Launch Another Program (any) From Your VB Program
Private Sub launchSLXAssist()
Dim intExecute%
If InStr(LCase(Command), "/interpreter") > 0 Then
MsgBox "Shell SLXAssist.exe"
Else
intExecute% = Shell("SLXAssist.exe /verified", 1)
End If
End Sub
Check if Network Path and File are available
Private Sub checkFile01()
' [step 1]: check to see if the network path and autoupdate.xml are available
Dim fLen As Integer
Dim strResponse%
tmr.Enabled = False
intbarProg = 0: barProg.Value = intbarProg
On Error Resume Next
fLen = Len(Dir$(xmlfilepath))
strResponse% = vbRetry
While strResponse% = vbRetry
If Err Or fLen = 0 Then
' file dosent exist
strResponse% = MsgBox("Error: XML inaccessible for auto-update!", vbAbortRetryIgnore, "SALESLOGIX ASSISTANT")
Else
' file exists
strResponse% = 0
End If
Wend
On Error GoTo 0
End Sub