-
Sep 20th, 2006, 08:39 AM
#1
Thread Starter
Hyperactive Member
[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:
Function OpenNotices(filename As String)
Dim InfoLine As String, a As Integer
[COLOR=Red]Open filename For Input As #1[/COLOR]' here the line
Do Until EOF(1)
DoEvents
Line Input #1, InfoLine
a = a + 1
AddToList InfoLine, a
Loop
Close #1
End Function
-
Sep 20th, 2006, 08:54 AM
#2
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?
-
Sep 20th, 2006, 09:12 AM
#3
-
Sep 20th, 2006, 10:15 AM
#4
Thread Starter
Hyperactive Member
Re: VB Runtime error 75
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.
-
Sep 21st, 2006, 03:57 AM
#5
Thread Starter
Hyperactive Member
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
-
Sep 21st, 2006, 04:44 AM
#6
Re: VB Runtime error 75
Does the folder and file actually exist?
Post the filename you got in your message (Debug.Print Filename).
-
Sep 21st, 2006, 07:36 AM
#7
Frenzied Member
Re: VB Runtime error 75
If you wrap this If statement around it:
VB Code:
If Dir(FileName) <> vbNullString Then
'code to open file
Else
MsgBox "file doesn't exist"
End If
Will you still get the error and will the code be executed?
(put a break on that line)
-
Sep 21st, 2006, 07:50 AM
#8
Fanatic Member
Re: VB Runtime error 75
Try changing the variable Filename to something else
-
Sep 21st, 2006, 03:04 PM
#9
Thread Starter
Hyperactive Member
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 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
-
Sep 21st, 2006, 03:49 PM
#10
Thread Starter
Hyperactive Member
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
-
Sep 21st, 2006, 03:53 PM
#11
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.
-
Sep 21st, 2006, 04:10 PM
#12
Thread Starter
Hyperactive Member
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:
Public IconObject As Object
Private Sub cmdAdd_Click()
If sDate(0).Value = True Then
AddNotice txtName.Text, Date, txtTime.Text, txtAbout.Text
Restore
Else
If txtName.Text <> "" Then
AddNotice txtName.Text, txtDate.Text, txtTime.Text, txtAbout.Text
Restore
Else
End If
End If
End Sub
Private Sub cmdMin_Click()
Me.Hide
End Sub
Private Sub cmdRemove_Click()
On Error Resume Next
If NoteCount <= 0 Then
Else
lstNotices.RemoveItem lstNotices.ListIndex
NoteCount = NoteCount - 1
End If
End Sub
Private Sub cmdView_Click()
On Error Resume Next
MsgBox GetInfo(lstNotices.List(lstNotices.ListIndex))
End Sub
Private Sub Form_Load()
Dim filename As String
txtTime.Text = Time
If FileExists(App.Path & "\notes.txt") = False Then
Open App.Path & "\notes.txt" For Output As #1
Print #1, ""
Close #1
Else
filename = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices")
OpenNotices filename
End If
Call savestring(HKEY_LOCAL_MACHINE, "Software\microsoft\windows\currentversion\run\", "Reminder", App.Path & "\reminder.exe")
Call savekey(HKEY_LOCAL_MACHINE, "Software\ReXz\")
NoteCount = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice")
Set IconObject = Me.Icon
AddIcon Me, IconObject.Handle, IconObject, "Reminder " & NoteCount & " notices"
lblNow.Caption = "Date && Time: " & Now
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Static Message As Long
Message = x / Screen.TwipsPerPixelX
Select Case Message
Case WM_LBUTTONDBLCLK:
Me.Show: Me.WindowState = vbNormal
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notice", Replace(Str(NoteCount), " ", ""))
SaveNotices App.Path & "\notes.txt"
delIcon IconObject.Handle
delIcon Me.Icon.Handle
End Sub
Private Sub lblNow_Change()
If NoteCount > 0 Then
CheckNotes
Else
End If
End Sub
Private Sub sDate_Click(Index As Integer)
If Index = 1 Then
txtDate.Visible = True
Else
txtDate.Visible = False
End If
End Sub
Private Sub Timer_Timer()
lblNow.Caption = "Date && Time: " & Now
End Sub
Function AddNotice(sName As String, sDate As String, sTime As String, Notice As String)
NoteCount = NoteCount + 1
Notes(NoteCount).sName = sName
Notes(NoteCount).sDate = sDate
Notes(NoteCount).sNotice = Notice
Notes(NoteCount).sTime = sTime
CheckName sName
End Function
Function CheckName(sName As String)
Dim i
For i = 0 To lstNotices.ListCount
If lstNotices.List(i) = sName Then
MsgBox "That name is allready used.", vbInformation + vbOKOnly, "Reminder"
Exit Function
Else
lstNotices.AddItem sName
Exit Function
End If
Next i
End Function
Function CheckNotes()
Dim c As Integer
For c = 0 To 100
If Date = Notes(c).sDate And Time = Notes(c).sTime Then
frmRemind.txtRemind.Text = Notes(c).sNotice: frmRemind.Show
sndPlaySound App.Path & "\note.wav", 1
RefreshList Notes(c).sName
ClearNote c
End If
Next c
End Function
Function ClearNote(Index As Integer)
Notes(Index).sDate = ""
Notes(Index).sName = ""
Notes(Index).sNotice = ""
Notes(Index).sTime = ""
NoteCount = NoteCount - 1
End Function
Function RefreshList(sName As String)
Dim s
For s = 0 To lstNotices.ListCount
If lstNotices.List(s) = sName Then
lstNotices.RemoveItem s
Exit Function
End If
Next s
End Function
Function Restore()
txtTime.Text = Time
txtAbout.Text = ""
txtName.Text = ""
End Function
Private Sub Timer1_Timer()
Me.Caption = "Reminder - " & NoteCount & " notices."
End Sub
Function OpenNotices(filename As String)
Dim InfoLine As String, a As Integer
MsgBox filename, vbExclamation, "file has to be found"
Open filename For Input As #1
Do Until EOF(1)
DoEvents
Line Input #1, InfoLine
a = a + 1
AddToList InfoLine, a
Loop
Close #1
End Function
Function AddToList(InfoLine As String, Index As Integer)
Dim info() As String
info = Split(InfoLine, "|")
If Index = NoteCount Then
Else
Notes(Index).sName = info(0)
Notes(Index).sNotice = Replace(info(1), "~", vbCrLf)
Notes(Index).sDate = info(2)
Notes(Index).sTime = info(3)
lstNotices.AddItem info(0)
End If
End Function
Function SaveNotices(filename As String)
Dim a As Integer
Open filename For Output As #1
Do Until a = NoteCount
DoEvents
a = a + 1
Print #1, Notes(a).sName & "|" & Replace(Notes(a).sNotice, vbCrLf, "~") & "|" & Notes(a).sDate & "|" & Notes(a).sTime
Loop
Call savestring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices", App.Path & "\notes.txt")
Close #1
End Function
Function GetInfo(sName As String) As String
Dim a As Integer
For a = 0 To 100
If sName = Notes(a).sName Then
GetInfo = "Name: " & Notes(a).sName & vbCrLf & "Initial Date & Time: " & Notes(a).sDate & " " & Notes(a).sTime & vbCrLf & "Notice: " & vbCrLf & Notes(a).sNotice
Exit Function
End If
Next a
End Function
Thanks
-
Sep 21st, 2006, 04:17 PM
#13
Re: VB Runtime error 75
It' still the same solution:
VB Code:
filename = getstring(HKEY_LOCAL_MACHINE, "Software\ReXz\", "Notices")
Debug.Print filename
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???
-
Sep 21st, 2006, 04:23 PM
#14
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
-
Sep 21st, 2006, 05:21 PM
#15
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:
Public Function GetAppPath() As String
Dim strPath As String
strPath = App.Path
If Right$(strPath, 1) = "\" Then
GetAppPath = strPath
Else
GetAppPath = strPath & "\"
End If
End Function
use it like this
VB Code:
Open GetAppPath & "notes.txt" For Output As #1
Last edited by 4x2y; Sep 21st, 2006 at 05:25 PM.
-
Sep 22nd, 2006, 04:40 AM
#16
Thread Starter
Hyperactive Member
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
-
Sep 22nd, 2006, 04:55 AM
#17
Re: [RESOLVED] VB Runtime error 75
don't use a Function (otherwise you have to run the code everytime):
VB Code:
' In a module
Public AppPath As String
' In your start-up sub, e.g.
Private Sub Form_Load()
If Right$(App.Path, 1) = "\" Then AppPath = App.Path Else AppPath = App.Path & "\"
End Sub
Now whenever you come to use App.Path use AppPath instead
-
Sep 22nd, 2006, 05:52 AM
#18
Thread Starter
Hyperactive Member
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.
-
Sep 22nd, 2006, 09:41 PM
#19
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:
'in a Sub Main
Public gblAppPath as string
Private Sub Main
gblAppPath = GetAppPath
End Sub
Private Function GetAppPath() As String
Dim strPath As String
strPath = App.Path
If Right$(strPath, 1) = "\" Then
GetAppPath = strPath
Else
GetAppPath = strPath & "\"
End If
End Function
I would then use gblAppPath everywhere that you currently use App.Path.
-
Sep 24th, 2006, 01:42 PM
#20
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|