It is rare, but i remember that i used error handler to check if a file exist (that was before i learn more professional way to do that)
Also in some cases if you want to know if the program is running inside the VB IDE or it is running as EXECode:Public Function IsFileExist(ByVal strFileName As String) As Boolean Dim dblFileLen As Double On Error GoTo FileNotExist dblFileLen = FileLen(strFileName) IsFileExist = True ' no error occurs, so the file exists. Exit Function FileNotExist: IsFileExist = False' an error occurs, so the file not exist. End Function
Code:Private Sub Command1_Click() On Error GoTo RunInsideIDE Debug.Print 0 / 0 ' This line will removed by the compiler when generating the exe. MsgBox "The program run as EXE" Exit Sub RunInsideIDE: MsgBox "The program run inside the IDE" End Sub





Reply With Quote