Results 1 to 24 of 24

Thread: [RESOLVED] Invalid Procedure Call Or Argument Stupid Error

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Resolved [RESOLVED] Invalid Procedure Call Or Argument Stupid Error

    For some reason I receive an error when running the following code:
    VB Code:
    1. 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,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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,
    Attached Files Attached Files
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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,
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Invalid Procedure Call Or Argument Stupid Error

    hmm, ok then but It might not make sense without the rest of it:
    VB Code:
    1. Private Sub Form_Load()
    2. Dim f As File
    3. Dim fsoStream As TextStream
    4. Dim rData As String, Bookmarks() As String
    5. Dim DelimPoint As Integer
    6.  
    7. Set fso = New FileSystemObject
    8. drpProfiles.Visible = False
    9. cmdGetBookmarks.Visible = False
    10. intIndex = -1
    11.  
    12. If fso.FileExists(App.Path & "\sitemonitor.db") = False Then
    13.     If MsgBox("Do You Wish To Import Your Firefox Bookmarks Now?", vbQuestion + vbYesNo, "Website Monitor") = vbYes Then
    14.         Call cmdImport_Click
    15.     End If
    16. Else
    17.     Set f = fso.GetFile(App.Path & "\sitemonitor.db")
    18.     Set fsoStream = f.OpenAsTextStream(ForReading)
    19.     rData = fsoStream.ReadAll
    20.     fsoStream.Close
    21.     Set fsoStream = Nothing
    22.     Set f = Nothing
    23.    
    24.     rData = Replace(rData, vbNewLine & vbNewLine, "")
    25.     Bookmarks() = Split(rData, vbNewLine)
    26.     For i = 0 To UBound(Bookmarks)
    27.         DelimPoint = InStr(1, Bookmarks(i), "::") - 1
    28.         Debug.Print "BKMRK " & i & " Length = " & Len(Bookmarks(i))
    29.         lstSites.AddItem Left$(Bookmarks(i), DelimPoint) 'CAUSING ERRORS, DAMMIT!
    30.         If Mid(Bookmarks(i), DelimPoint + 3) = 1 Then
    31.             lstSites.Selected(i) = True
    32.         End If
    33.     Next i
    34. End If
    35.  
    36. i = 0
    37. Do Until i = lstSites.ListCount
    38.     If lstSites.List(i) = vbNullString Then
    39.         lstSites.RemoveItem (i)
    40.         i = i - 1
    41.     End If
    42. Loop
    43. Debug.Print "Number Of Bookmarks: " & lstSites.ListCount
    44.  
    45. Set fso = Nothing
    46. End Sub
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  7. #7
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Invalid Procedure Call Or Argument Stupid Error

    try to replace your error line with this code:

    VB Code:
    1. If DelimPoint >= Len(Bookmarks(i)) Then
    2.             MsgBox "ERROR on item number " & i
    3.         Else
    4.             lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
    5.         End If

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Invalid Procedure Call Or Argument Stupid Error

    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Invalid Procedure Call Or Argument Stupid Error

    This is the strangest thing, if I change the line
    VB Code:
    1. lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
    To this:
    VB Code:
    1. 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.
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  11. #11
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    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
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  12. #12
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Invalid Procedure Call Or Argument Stupid Error

    How many bookmarks are there? Maybe try replacing the listbox with listview.

  13. #13
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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:
    1. Private Sub lstSites_ItemCheck(Item As Integer)
    2. If intIndex > -1 Then
    3.     For i = 0 To intIndex
    4.         If CheckedItems(i) = Item Then ' Item Is Being Unticked
    5.             CheckedItems(i) = -1 'Similar To Removing Item
    6.             Exit Sub
    7.         End If
    8.     Next i
    9. End If
    10.  
    11. intIndex = intIndex + 1
    12. ReDim Preserve CheckedItems(intIndex)
    13. CheckedItems(intIndex) = Item
    14. End Sub

    it might be that every item you add (and check it) it will get triggered and might get you stuck somewhere.

  14. #14
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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:
    1. lstSites.AddItem Left$(Bookmarks(i), DelimPoint)
    To this:
    VB Code:
    1. 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??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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.
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  16. #16
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Invalid Procedure Call Or Argument Stupid Error

    OK, let me try it out...
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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??
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  19. #19
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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.

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    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?
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  21. #21
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  22. #22
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Invalid Procedure Call Or Argument Stupid Error

    try stepping thru it. if it works, then try solving timing issues.

  23. #23
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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).

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Invalid Procedure Call Or Argument Stupid Error

    Woo hooo!
    I fixed it, the problem was with
    VB Code:
    1. i = 0
    2. Do Until i = lstSites.ListCount
    3.     If lstSites.List(i) = vbNullString Then
    4.         lstSites.RemoveItem (i)
    5.         i = i - 1
    6.     End If
    7. Loop
    Thank you to everyone who gave me advice here!
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

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