error:variable not defined?????
Code:
Private Sub mnuFileMRU_Click(index As Integer)
strFileNewName1 = (Left(mnuFileMRU(index).Caption, InStr(1, mnuFileMRU(index).Caption, "\DAF")) & "Map\")
strFileNewName2 = (Mid(mnuFileMRU(index).Caption, InStr(1, mnuFileMRU(index).Caption, "MY"), 8) & ".bmp")
strFileNewName3 = strFileNewName1 & strFileNewName2
'MsgBox " " & strFileNewName3
Picture1.Picture = LoadPicture(strFileNewName3)
Call ConvertMRU
End Sub
Private Sub ConvertMRU()
Dim intFF As Integer
Dim strReaded() As String
Dim index as integer
intFF = FreeFile
Open mnuFileMRU(index).Caption For Input As #intFF
strReaded = Split(Input(LOF(intFF), #intFF), vbLf)
Close #intFF
strFileNewName4 = (Left(mnuFileMRU(index).Caption, InStr(1, mnuFileMRU(index).Caption, "\DAF")) & "Setting\Daf.txt")
'MsgBox "" & strFileNewName4
intFF = FreeFile
Open strFileNewName4 For Output As #intFF
Print #intFF, Join(strReaded, vbCrLf);
Close #intFF
End Sub
above is part of my code. it came out an error "variable not defined" and point to index(the red color). how to improve the code above?
Re: error:variable not defined?????
If your menu items are not in an array, then there will be no index property, and the result will be an error.
If you are using my example to create an MRU, have you created your menu array that will be populated with the most recently used items?
Re: error:variable not defined?????
Quote:
Originally Posted by Hack
If your menu items are not in an array, then there will be no index property, and the result will be an error.
If you are using my example to create an MRU, have you created your menu array that will be populated with the most recently used items?
yes, i used your example to edit. when i add the code ( the blue color in #1).the error became as "control array element '0" doesn't exist"
Re: error:variable not defined?????
You need to make a menu array in design time.
Open the project in my attachment and look at the menu I created on the form. Under CleanMRU you will see a bunch of menu items with no caption, and a sequential index number.
That index number is what the code is looking for, and what you do not have.
Re: error:variable not defined?????
Quote:
Originally Posted by Hack
You need to make a menu array in design time.
Open the project in my attachment and look at the menu I created on the form. Under CleanMRU you will see a bunch of menu items with no caption, and a sequential index number.
That index number is what the code is looking for, and what you do not have.
i had a sequential index number from 1 to 4.
Re: error:variable not defined?????
Re: error:variable not defined?????
Quote:
Originally Posted by VaRz
hmm
then try out a loop
Code:
Private Sub ConvertMRU()
Dim intFF As Integer
Dim strReaded() As String
Dim i As Integer
intFF = FreeFile
For i = 1 To 4
Open mnuFileMRU(i).Caption For Input As #intFF
strReaded = Split(Input(LOF(intFF), #intFF), vbLf)
Close #intFF
MsgBox "" & mnuFileMRU(i) strFileNewName4 = (Left(mnuFileMRU(i).Caption, InStr(1, mnuFileMRU(i).Caption, "\DAF")) & "Setting\Daf.txt")
intFF = FreeFile
Open strFileNewName4 For Output As #intFF
Print #intFF, Join(strReaded, vbCrLf);
Close #intFF
Next
End Sub
i try the loop. but by using the message box ( the red line). it came out the message "true" not the directory of file. why?????
Re: error:variable not defined?????
Attach your form so I can take a look at it.
1 Attachment(s)
Re: error:variable not defined?????
i have attact the code. please open the file MY3C0540.daf in forder DAF first. then close it and try again with MRU.