i am using the following code which checks if a file exists if not it creates a file
but when i click load it says "bad file mode"Code:Private Sub cmdload_Click() Dim fs As Object Set fs = CreateObject("Scripting.FileSystemObject") If FileExists("test.txt") Then Open "est.txt" For Input As #1 Print #1, label1.Caption Close #1 Else Call create_test End If End Sub Sub create_test() Open "test.txt" For Append As 1 Print #6, label1.Caption Close 6 End Sub Function FolderExists(sPath As String) As Boolean FolderExists = CreateObject("Scripting.FileSystemObject").FolderExists(sPath) End Function Function FileExists(sFullFileName As String) As Boolean FileExists = CreateObject("Scripting.FileSystemObject").FileExists(sFullFileName) End Function
what want to do is if after click load the file does not exist then it creates a file and loades the value in label1. but it seems i am doing something wrong. any ideas




Reply With Quote