jgoodman00
Programmer
- Jan 23, 2001
- 1,510
I have the following code in a module, to check if a file exists:
Function CheckFileExists(ByVal IN_FILENAME As String) As Integer
Dim iresult As Integer
Dim strucFname As OFSTRUCT
Dim strSearchFile As String
strSearchFile = IN_FILENAME
iresult = OpenFile(strSearchFile, strucFname, OF_EXIST)
'The above line causes OpenFile to search for the
'file Test on the server network path.
'Passing the OF_EXIST parameter tells the OpenFile
'function to search for the file, the file will not be
'opened or modified in any way.
CheckFileExists = iresult
End Function
I then have the following code under a button in a form:
Private Sub VegGide_Click()
On Error GoTo Err_VegGide_Click
Dim stAppName As String
GeoOutlook:
If CheckFileExists("C:\Bentley\Program\GeoOutlook\geooutlk.exe" = True Then
stAppName = "C:\Bentley\Program\GeoOutlook\geooutlk.exe c:\gide\standard\work\gide.dgn -wdodbc"
ElseIf CheckFileExists("C:\Bentley\Program\GeoOutlook\geooutlk.exe" = False Then
GoTo Microstation
End If
Microstation:
If CheckFileExists("C:\WIN32APP\ustation\USTATION.EXE" = True Then
stAppName = "C:\WIN32APP\ustation\USTATION.EXE c:\gide\standard\work\gide.dgn -wdodbc -wustandard1"
ElseIf CheckFileExists("C:\WIN32APP\ustation\USTATION.EXE" = False Then
GoTo VegGide_Err
End If
VegGide_Err:
MsgBox "A Compatible viewer could not be found, press OK to continue", vbOKOnly
Exit Sub
Exit_VegGide_Click:
Exit Sub
Err_VegGide_Click:
MsgBox Err.Description
Resume Exit_VegGide_Click
End Sub
As you can see, the idea is that the function executes & returns either a true or a false. This part works, but for some reason the result just disappears before the next line of code can get it. Does anyone have any suggestions as to what my code should be???
James Goodman
Function CheckFileExists(ByVal IN_FILENAME As String) As Integer
Dim iresult As Integer
Dim strucFname As OFSTRUCT
Dim strSearchFile As String
strSearchFile = IN_FILENAME
iresult = OpenFile(strSearchFile, strucFname, OF_EXIST)
'The above line causes OpenFile to search for the
'file Test on the server network path.
'Passing the OF_EXIST parameter tells the OpenFile
'function to search for the file, the file will not be
'opened or modified in any way.
CheckFileExists = iresult
End Function
I then have the following code under a button in a form:
Private Sub VegGide_Click()
On Error GoTo Err_VegGide_Click
Dim stAppName As String
GeoOutlook:
If CheckFileExists("C:\Bentley\Program\GeoOutlook\geooutlk.exe" = True Then
stAppName = "C:\Bentley\Program\GeoOutlook\geooutlk.exe c:\gide\standard\work\gide.dgn -wdodbc"
ElseIf CheckFileExists("C:\Bentley\Program\GeoOutlook\geooutlk.exe" = False Then
GoTo Microstation
End If
Microstation:
If CheckFileExists("C:\WIN32APP\ustation\USTATION.EXE" = True Then
stAppName = "C:\WIN32APP\ustation\USTATION.EXE c:\gide\standard\work\gide.dgn -wdodbc -wustandard1"
ElseIf CheckFileExists("C:\WIN32APP\ustation\USTATION.EXE" = False Then
GoTo VegGide_Err
End If
VegGide_Err:
MsgBox "A Compatible viewer could not be found, press OK to continue", vbOKOnly
Exit Sub
Exit_VegGide_Click:
Exit Sub
Err_VegGide_Click:
MsgBox Err.Description
Resume Exit_VegGide_Click
End Sub
As you can see, the idea is that the function executes & returns either a true or a false. This part works, but for some reason the result just disappears before the next line of code can get it. Does anyone have any suggestions as to what my code should be???
James Goodman