-
[RESOLVED] Invalid Procedure Call Or Argument Stupid Error
For some reason I receive an error when running the following code:
VB Code:
lstSites.AddItem Left(Bookmarks(i), DelimPoint)
I know that its out of context but I am sure that there is a simple way to sort this out. DelimPoint is a valid integer that is less than the length of Bookmarks(i).
Any help would be appreciated,
-
Re: Invalid Procedure Call Or Argument Stupid Error
I dont see any problems here. Can you post more code and possible some sample data?
Also, you should use Left$ instead of Left, it is much faster as it does not work with Variant.
-
1 Attachment(s)
Re: Invalid Procedure Call Or Argument Stupid Error
Ok, thanx 4 the tip, I replaced all the 'Left's with Left$
erm, the code is kinda in the middle of everything, I'll try give you an idea of it.
Ahh, screw it. I'll post my project here.
Its going to be a sort of Personal Assistant to help the user with tasks.
The error I am receiving occurs on frmSiteMonitor (Which is meant to import the bookmarks from Firefox and then alert the user when a site is updated)
I havent yet coded most of it, I am receiving the error when the program loads saved bookmarks so you will need to import your firefox bookmarks and then exit the program (click the 'x' in the program so that it can use its Form_Unload to save the bookmarks)
Once you've done that open the program again and it should freeze up or give you the error.
The error occurs in frmSiteMonitor Form_Load()
ps: Do you have MSN where we can chat easier?
Thanx,
-
Re: Invalid Procedure Call Or Argument Stupid Error
I dont have Firefox nor MSN :), but this way others can see the posts and kick in with suggestions.
You forgot to upload the project, but in any case, you can just post the Form_Load event in which the error occurs and I will check it out.
Regarding the Left, same goes for other stuff like Right$, Mid$ and so on. a lot of functions have the variant and string version.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Oh I forgot, you need to skip the main form when doing all of the above things so use the menu on frmMain to go to the Site Monitor Form and then do what I said above.
Thanx,
-
Re: Invalid Procedure Call Or Argument Stupid Error
hmm, ok then but It might not make sense without the rest of it:
VB Code:
Private Sub Form_Load()
Dim f As File
Dim fsoStream As TextStream
Dim rData As String, Bookmarks() As String
Dim DelimPoint As Integer
Set fso = New FileSystemObject
drpProfiles.Visible = False
cmdGetBookmarks.Visible = False
intIndex = -1
If fso.FileExists(App.Path & "\sitemonitor.db") = False Then
If MsgBox("Do You Wish To Import Your Firefox Bookmarks Now?", vbQuestion + vbYesNo, "Website Monitor") = vbYes Then
Call cmdImport_Click
End If
Else
Set f = fso.GetFile(App.Path & "\sitemonitor.db")
Set fsoStream = f.OpenAsTextStream(ForReading)
rData = fsoStream.ReadAll
fsoStream.Close
Set fsoStream = Nothing
Set f = Nothing
rData = Replace(rData, vbNewLine & vbNewLine, "")
Bookmarks() = Split(rData, vbNewLine)
For i = 0 To UBound(Bookmarks)
DelimPoint = InStr(1, Bookmarks(i), "::") - 1
Debug.Print "BKMRK " & i & " Length = " & Len(Bookmarks(i))
lstSites.AddItem Left$(Bookmarks(i), DelimPoint) 'CAUSING ERRORS, DAMMIT!
If Mid(Bookmarks(i), DelimPoint + 3) = 1 Then
lstSites.Selected(i) = True
End If
Next i
End If
i = 0
Do Until i = lstSites.ListCount
If lstSites.List(i) = vbNullString Then
lstSites.RemoveItem (i)
i = i - 1
End If
Loop
Debug.Print "Number Of Bookmarks: " & lstSites.ListCount
Set fso = Nothing
End Sub
-
Re: Invalid Procedure Call Or Argument Stupid Error
try to replace your error line with this code:
VB Code:
If DelimPoint >= Len(Bookmarks(i)) Then
MsgBox "ERROR on item number " & i
Else
lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
End If
-
Re: Invalid Procedure Call Or Argument Stupid Error
-
Re: Invalid Procedure Call Or Argument Stupid Error
I just tried that but it didn't work, just froze up the IDE - thatz what happens now, it doesnt show the error, just freezes up
-
Re: Invalid Procedure Call Or Argument Stupid Error
This is the strangest thing, if I change the line
VB Code:
lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
To this:
VB Code:
Debug.Print Left$(Bookmarks(i), DelimPoint)
It prints all of the bookmarks perfectly fine, only when trying to add them to the listbox does it mess up.
-
Re: Invalid Procedure Call Or Argument Stupid Error
I have not viewed the code or entire but what I dowbt the problem is that Bookmarks(i) is a null value.
Just confirm that Bookmarks(i) is not null when the error occurs.
Pradeep
-
Re: Invalid Procedure Call Or Argument Stupid Error
How many bookmarks are there? Maybe try replacing the listbox with listview.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Also, I am not sure how your code goes, but this event might be the problem:
VB Code:
Private Sub lstSites_ItemCheck(Item As Integer)
If intIndex > -1 Then
For i = 0 To intIndex
If CheckedItems(i) = Item Then ' Item Is Being Unticked
CheckedItems(i) = -1 'Similar To Removing Item
Exit Sub
End If
Next i
End If
intIndex = intIndex + 1
ReDim Preserve CheckedItems(intIndex)
CheckedItems(intIndex) = Item
End Sub
it might be that every item you add (and check it) it will get triggered and might get you stuck somewhere.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Quote:
Originally Posted by shirazamod
This is the strangest thing, if I change the line
VB Code:
lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
To this:
VB Code:
Debug.Print Left$(Bookmarks(i), DelimPoint)
It prints all of the bookmarks perfectly fine, only when trying to add them to the listbox does it mess up.
Is the listbox available yet? You say this code is in the FORM_LOAD event??
-
Re: Invalid Procedure Call Or Argument Stupid Error
szlammy, I think you've got it. when i replaced that line with lstSites.additem "hello"
the program froze up!
How do I make the listbox available?
baja_yu, I don't think that the item checking is a problem coz I removed that part an it still didn't work.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Move the code to the Form_Activate event. Form_Load fires as the form is loading, and before the listbox is on-screen.
-
Re: Invalid Procedure Call Or Argument Stupid Error
-
Re: Invalid Procedure Call Or Argument Stupid Error
hmm...
Now it seems to load the data into the listbox but then it freezes over.
I can see the first item in the listbox and I can see the scrollbar appear in the right size so that approx. the right amount of items are added but then it just freezes.
Any ideas??
-
Re: Invalid Procedure Call Or Argument Stupid Error
Press F9 to place a breakpoint in where it adds the first item, then press F8 to step thru it to see where it hangs up. Remove any On Error statements. They might be masking something also, especially if you have a Resume Next.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Don't have any on error, I found that it is going into an infinite loop.
Any ideas why it would do that?
-
Re: Invalid Procedure Call Or Argument Stupid Error
Does it freeze indefinitelly, or for a period of time? If it is the second one, then it is because it needs some time to load. What you should do is this, before loading code make the list invisible
List1.Visible = False
and after loading set it to visible again
List1.Visible = True
Also, add a DoEvents like in the loading For loop.
-
Re: Invalid Procedure Call Or Argument Stupid Error
try stepping thru it. if it works, then try solving timing issues.
-
Re: Invalid Procedure Call Or Argument Stupid Error
Where and why does it go into an infinite loop? Check your values (the Ubound of Bookmarks).
-
Re: Invalid Procedure Call Or Argument Stupid Error
Woo hooo!
I fixed it, the problem was with
VB Code:
i = 0
Do Until i = lstSites.ListCount
If lstSites.List(i) = vbNullString Then
lstSites.RemoveItem (i)
i = i - 1
End If
Loop
Thank you to everyone who gave me advice here!