Results 1 to 20 of 20

Thread: [RESOLVED] VB Runtime error 75

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Resolved [RESOLVED] VB Runtime error 75

    Hi once more, I am in a very irritating situation whereby I run code on my development machine I get no error, However when I try it on a test machine I get vb runtime error stating path not found. I have added the Microsoft scripting runtime reference and even included VB6 service pack 5 but dont get any change. The only difference I got on one of my test machines is that when I compiled it the the code ran pretty well, and on similar machines (ie same specs). The code in question shown below. Cheers
    VB Code:
    1. Function OpenNotices(filename As String)
    2. Dim InfoLine As String, a As Integer
    3. [COLOR=Red]Open filename For Input As #1[/COLOR]' here the line
    4. Do Until EOF(1)
    5. DoEvents
    6. Line Input #1, InfoLine
    7. a = a + 1
    8. AddToList InfoLine, a
    9. Loop
    10. Close #1
    11. End Function

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Runtime error 75

    runtime error 75 isn't file not found

    anyway, is filename a valid file on the test computer? what do you get if you put MsgBox filename before the Open statement, does it show a valid file path?

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: VB Runtime error 75


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Smile Re: VB Runtime error 75

    Quote Originally Posted by bushmobile
    runtime error 75 isn't file not found

    anyway, is filename a valid file on the test computer? what do you get if you put MsgBox filename before the Open statement, does it show a valid file path?
    Hi Bushmobile and Co the site denied me giving some rates anyway I will sort that out. G thanks for the trick supplied in your answer it did get me well ahead. However when I use the "Msg filename", it gives me the location of the same path I use for file on developer machine and test machine. What could be the problem and what possible remedies can one execute to avoid such an issue. Cheers.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: VB Runtime error 75

    Hey folks I used the trick as advised by Bushmobile but still got same error coming up runtime error 75 path/file not found. Can someone please give me a hint to how I can solve this ? Thanks

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: VB Runtime error 75

    Does the folder and file actually exist?
    Post the filename you got in your message (Debug.Print Filename).

  7. #7
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: VB Runtime error 75

    If you wrap this If statement around it:
    VB Code:
    1. If Dir(FileName) <> vbNullString Then
    2.     'code to open file
    3. Else
    4.     MsgBox "file doesn't exist"
    5. End If
    Will you still get the error and will the code be executed?
    (put a break on that line)

  8. #8
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: VB Runtime error 75

    Try changing the variable Filename to something else

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: VB Runtime error 75

    I out there and thanks for the interesting tips and tricks coupling Bushmobiles and Jeroen79's tips I got this line
    VB Code:
    1. Msg Dir(filename )
    before the code and ........................ on behold I got the name of a different file in the same Directory as the file I was actually looking for. The only eyebrow raising issue is that they are both text files. Interesting, however from here what next ? Cheers

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: VB Runtime error 75

    Afetr changing the directories of all similar text files, the string instead opens a completely different file *.ico whreas I am looking for a *.txt file in the same folder which Does exist with valid Directory. This really is an issue. Cheers

  11. #11
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: VB Runtime error 75

    It is however really amazing how one would ignore the simple things like posting what is in the filename before it is attempted to be opened. There is no way one filename is passed and another opened.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: VB Runtime error 75

    Thanks for the the support Randem. Actually there is memo information in the file hence its not empty. Hence it had stored the last entry I posted into. As to getting to open the file while making sure other similar situations must be closed I think the whole stretch of code will do to sort this out.
    VB Code:
    1. Public IconObject As Object
    2. Private Sub cmdAdd_Click()
    3. If sDate(0).Value = True Then
    4. AddNotice txtName.Text, Date, txtTime.Text, txtAbout.Text
    5. Restore
    6. Else
    7. If txtName.Text <> "" Then
    8. AddNotice txtName.Text, txtDate.Text, txtTime.Text, txtAbout.Text
    9. Restore
    10. Else
    11. End If
    12. End If
    13. End Sub
    14. Private Sub cmdMin_Click()
    15. Me.Hide
    16. End Sub
    17.  
    18. Private Sub cmdRemove_Click()
    19. On Error Resume Next
    20. If NoteCount <= 0 Then
    21. Else
    22. lstNotices.RemoveItem lstNotices.ListIndex
    23. NoteCount = NoteCount - 1
    24. End If
    25. End Sub
    26.  
    27. Private Sub cmdView_Click()
    28. On Error Resume Next
    29. MsgBox GetInfo(lstNotices.List(lstNotices.ListIndex))
    30. End Sub
    31.  
    32. Private Sub Form_Load()
    33. Dim filename As String
    34. txtTime.Text = Time
    35. If FileExists(App.Path & "\notes.txt") = False Then
    36. Open App.Path & "\notes.txt" For Output As #1
    37. Print #1, ""
    38. Close #1
    39. Else
    40. filename = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices")
    41. OpenNotices filename
    42. End If
    43. Call savestring(HKEY_LOCAL_MACHINE, "Software\microsoft\windows\currentversion\run\", "Reminder", App.Path & "\reminder.exe")
    44. Call savekey(HKEY_LOCAL_MACHINE, "Software\ReXz\")
    45. NoteCount = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice")
    46. Set IconObject = Me.Icon
    47. AddIcon Me, IconObject.Handle, IconObject, "Reminder " & NoteCount & " notices"
    48. lblNow.Caption = "Date && Time: " & Now
    49. End Sub
    50.  
    51. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    52.     Static Message As Long
    53.     Message = x / Screen.TwipsPerPixelX
    54.     Select Case Message
    55.     Case WM_LBUTTONDBLCLK:
    56.         Me.Show: Me.WindowState = vbNormal
    57.     End Select
    58. End Sub
    59.  
    60. Private Sub Form_Unload(Cancel As Integer)
    61. Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice", Replace(Str(NoteCount), " ", ""))
    62.  
    63. SaveNotices App.Path & "\notes.txt"
    64.  
    65.     delIcon IconObject.Handle
    66.     delIcon Me.Icon.Handle
    67. End Sub
    68.  
    69. Private Sub lblNow_Change()
    70. If NoteCount > 0 Then
    71. CheckNotes
    72. Else
    73. End If
    74. End Sub
    75. Private Sub sDate_Click(Index As Integer)
    76. If Index = 1 Then
    77. txtDate.Visible = True
    78. Else
    79. txtDate.Visible = False
    80. End If
    81. End Sub
    82.  
    83. Private Sub Timer_Timer()
    84. lblNow.Caption = "Date && Time: " & Now
    85. End Sub
    86.  
    87. Function AddNotice(sName As String, sDate As String, sTime As String, Notice As String)
    88. NoteCount = NoteCount + 1
    89. Notes(NoteCount).sName = sName
    90. Notes(NoteCount).sDate = sDate
    91. Notes(NoteCount).sNotice = Notice
    92. Notes(NoteCount).sTime = sTime
    93. CheckName sName
    94. End Function
    95.  
    96. Function CheckName(sName As String)
    97. Dim i
    98. For i = 0 To lstNotices.ListCount
    99. If lstNotices.List(i) = sName Then
    100. MsgBox "That name is allready used.", vbInformation + vbOKOnly, "Reminder"
    101. Exit Function
    102. Else
    103. lstNotices.AddItem sName
    104. Exit Function
    105. End If
    106. Next i
    107. End Function
    108.  
    109. Function CheckNotes()
    110. Dim c As Integer
    111. For c = 0 To 100
    112. If Date = Notes(c).sDate And Time = Notes(c).sTime Then
    113. frmRemind.txtRemind.Text = Notes(c).sNotice: frmRemind.Show
    114. sndPlaySound App.Path & "\note.wav", 1
    115. RefreshList Notes(c).sName
    116. ClearNote c
    117. End If
    118. Next c
    119. End Function
    120. Function ClearNote(Index As Integer)
    121. Notes(Index).sDate = ""
    122. Notes(Index).sName = ""
    123. Notes(Index).sNotice = ""
    124. Notes(Index).sTime = ""
    125. NoteCount = NoteCount - 1
    126. End Function
    127.  
    128. Function RefreshList(sName As String)
    129. Dim s
    130. For s = 0 To lstNotices.ListCount
    131. If lstNotices.List(s) = sName Then
    132. lstNotices.RemoveItem s
    133. Exit Function
    134. End If
    135. Next s
    136. End Function
    137.  
    138. Function Restore()
    139. txtTime.Text = Time
    140. txtAbout.Text = ""
    141. txtName.Text = ""
    142. End Function
    143.  
    144. Private Sub Timer1_Timer()
    145. Me.Caption = "Reminder - " & NoteCount & " notices."
    146. End Sub
    147.  
    148. Function OpenNotices(filename As String)
    149. Dim InfoLine As String, a As Integer
    150. MsgBox filename, vbExclamation, "file has to be found"
    151. Open filename For Input As #1
    152. Do Until EOF(1)
    153. DoEvents
    154. Line Input #1, InfoLine
    155. a = a + 1
    156. AddToList InfoLine, a
    157. Loop
    158. Close #1
    159. End Function
    160.  
    161. Function AddToList(InfoLine As String, Index As Integer)
    162. Dim info() As String
    163. info = Split(InfoLine, "|")
    164. If Index = NoteCount Then
    165. Else
    166. Notes(Index).sName = info(0)
    167. Notes(Index).sNotice = Replace(info(1), "~", vbCrLf)
    168. Notes(Index).sDate = info(2)
    169. Notes(Index).sTime = info(3)
    170. lstNotices.AddItem info(0)
    171. End If
    172. End Function
    173.  
    174. Function SaveNotices(filename As String)
    175. Dim a As Integer
    176. Open filename For Output As #1
    177. Do Until a = NoteCount
    178. DoEvents
    179. a = a + 1
    180. Print #1, Notes(a).sName & "|" & Replace(Notes(a).sNotice, vbCrLf, "~") & "|" & Notes(a).sDate & "|" & Notes(a).sTime
    181. Loop
    182. Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices", App.Path & "\notes.txt")
    183. Close #1
    184. End Function
    185.  
    186. Function GetInfo(sName As String) As String
    187. Dim a As Integer
    188. For a = 0 To 100
    189. If sName = Notes(a).sName Then
    190. GetInfo = "Name: " & Notes(a).sName & vbCrLf & "Initial Date & Time: " & Notes(a).sDate & " " & Notes(a).sTime & vbCrLf & "Notice: " & vbCrLf & Notes(a).sNotice
    191. Exit Function
    192. End If
    193. Next a
    194. End Function
    Thanks

  13. #13
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: VB Runtime error 75

    It' still the same solution:
    VB Code:
    1. filename = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices")
    2. Debug.Print filename
    3. OpenNotices filename
    Then post what gets printed to the immediate window in the IDE. Of course put a breakpoint on the OpenNotices line. I imagine this is where you are having the problem???

  14. #14
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: VB Runtime error 75

    it is better to post the code you use to build the file name you are going to open, the problem is there

    there are many debugging techniqus you can use to figure out where the wrong code

    from Debug menu add break points on the lines you are doubt on it, and when the execution break check your variables if it contains the expected data or not

    also you can use Add Watch... from Debug menu to add a variable that you want to watch and select Break When Value Change option, if you use a public variable its value maybe changed in unexpected places

    also there is debug step into (F8) it is very useful too

    Good Luck

  15. #15
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: VB Runtime error 75

    Well, after review your code i cannot figure out where the problem
    anyway i discovered something wrong, i doubt it cause all these proplems, that is you always using App.Path & "\file_name" indeed using App.Path this way is wrong and can cause many errors
    imagine that your exe is in the drive root dir say "C:\", in this case App.Path will return C:\ not C: as you expected. So exprisson like this App.Path & "\notes.txt" will return C:\\notes.txt

    therefore i have create a function to return the correct path

    VB Code:
    1. Public Function GetAppPath() As String
    2.     Dim strPath As String
    3.     strPath = App.Path
    4.     If Right$(strPath, 1) = "\" Then
    5.         GetAppPath = strPath
    6.     Else
    7.         GetAppPath = strPath & "\"
    8.     End If
    9. End Function

    use it like this
    VB Code:
    1. Open GetAppPath & "notes.txt" For Output As #1
    Last edited by 4x2y; Sep 21st, 2006 at 05:25 PM.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: VB Runtime error 75

    Thanks for the Xtra load of lessons that came in. Ive leant a great deal from the advise given and replaced the line with the Function given above . Horay............ it worked ! Cheers

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] VB Runtime error 75

    don't use a Function (otherwise you have to run the code everytime):
    VB Code:
    1. ' In a module
    2. Public AppPath As String
    3.  
    4. ' In your start-up sub, e.g.
    5. Private Sub Form_Load()
    6.     If Right$(App.Path, 1) = "\" Then AppPath = App.Path Else AppPath = App.Path & "\"
    7. End Sub
    Now whenever you come to use App.Path use AppPath instead

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: [RESOLVED] VB Runtime error 75

    Uhm thats thats very interesting I am going to try that out too, than do alot of testing. Thanks once more.

  19. #19
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: [RESOLVED] VB Runtime error 75

    The App.Path situation is from earlier OS handling App.Path differently So that routine should be mandatory. I have one like that that all my apps use. I set up a variable at the beginning of my programs that contain the newly create App.Path and use that everytime I want to use the application path name.

    Ex.
    VB Code:
    1. 'in a Sub Main
    2. Public gblAppPath as string
    3.  
    4. Private Sub Main
    5.  
    6. gblAppPath = GetAppPath
    7.  
    8. End Sub
    9.  
    10.  
    11. Private Function GetAppPath() As String
    12.     Dim strPath As String
    13.     strPath = App.Path
    14.     If Right$(strPath, 1) = "\" Then
    15.         GetAppPath = strPath
    16.     Else
    17.         GetAppPath = strPath & "\"
    18.     End If
    19. End Function

    I would then use gblAppPath everywhere that you currently use App.Path.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    352

    Re: [RESOLVED] VB Runtime error 75

    Yo, Randem ure back,thank you all for your relentless assistance in the abovementioned issue. I have not only learnt some new tricks but enjoyed a slightly debated aproach. For all of you who have contibuted, Bushmobile,4x2y, randem, jeroen and Co, ure assistance has been worthwhile. Not only have I ended up with a solution to my problem I have gained a number of similar approaches to such scenarios and will take my time to appreciate all. Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width