Results 1 to 13 of 13

Thread: [RESOLVED] Run Time Error "5"

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Resolved [RESOLVED] Run Time Error "5"

    i had to reformat and i lost all my projects...well one lintz helped me with so i just copied and pasted what he showed me for now until i get time to do the rest of what i had on it finished...
    well when i try to search i now get a Run Time Error '5' Invalid procedure call or argument and it highlights this line
    VB Code:
    1. EndPos = InStr(pos, sSource, "</table>")
    i didnt change any of that part which lintz showed me so im really confused as to why its doing it now
    also the
    VB Code:
    1. On Error GoTo CheckErrorNo
    comes up as label not defined
    the previous post is here
    HTML Code:
    http://vbforums.com/showthread.php?t=428414

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Run Time Error "5"

    VB Code:
    1. On Error GoTo CheckErrorNo
    2.  
    3.     'your code...
    4.  
    5. CheckErrorNo: 'you probobally forgot about this line

  3. #3
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: Run Time Error "5"

    Maybe he did , also don't forget to add :
    VB Code:
    1. Exit Sub
    before the label
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Re: Run Time Error "5"

    i had all that in correctly i was able to recover the form but it was a bit messed up after the format anyways i tried just this
    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    2. Const SW_SHOWNORMAL = 1
    3.  
    4. Dim pos As Long
    5. Dim sSource As String
    6. Dim EndPos As Long
    7. Dim i As Integer
    8. Dim FileName As String
    9.  
    10. Dim Itmx As ListItem
    11. Dim SiteLink As String
    12.  
    13. Private Sub Command1_Click()
    14. sSource = Inet1.OpenURL("http://www.mininova.org/search/?search=for+dummies")
    15.  
    16. 'Find where the resutls table starts
    17. pos = InStr(1, sSource, "class=""maintable")
    18. EndPos = InStr(pos, sSource, "</table>")
    19.  
    20. 'Find where "results" start
    21. pos = InStr(pos, sSource, "<tr>")
    22. pos = InStr(pos + 1, sSource, "<tr>")
    23.  
    24. 'loop through tabled results
    25.     Do While pos < EndPos
    26.    
    27.         'find the 3rd instance of <A HREF> as we can get name of file
    28.         For i = 1 To 3
    29.         pos = InStr(pos + 1, sSource, "<a href")
    30.         Next
    31.    
    32.    
    33.     'find where link starts "/"
    34.     pos = InStr(pos, sSource, "/") + 1
    35.     SiteLink = Mid$(sSource, pos, InStr(pos, sSource, ">") - pos - 1)
    36.    
    37.     'find ">"
    38.     pos = InStr(pos, sSource, ">") + 1
    39.     'find file name
    40.     FileName = Mid$(sSource, pos, InStr(pos, sSource, "<") - pos)
    41.  
    42.  
    43.     SiteLink = "http://www.mininova.org/" & SiteLink
    44.     'Add to listview
    45.     Set Itmx = ListView1.ListItems.Add(, SiteLink, FileName)
    46.  
    47.     'find next "<tr>" for next result
    48.     pos = InStr(pos, sSource, "<tr") + 1
    49.      
    50.         'end of table results
    51.         If pos = 1 Then
    52.         Exit Do
    53.         End If
    54.        
    55.     DoEvents
    56.    
    57.     Loop
    58.    
    59.  
    60.    
    61. MsgBox "Complete"
    62. End Sub
    63.  
    64. Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    65.  
    66. ShellExecute Me.hWnd, "Open", Item.Key, 0, 0, 3
    67.  
    68. End Sub
    and it still errors out on this line
    VB Code:
    1. EndPos = InStr(pos, sSource, "</table>")
    ive went through the code and site and from what i can see nothing has changed so im pretty bewildered as to why its doing this error...would i have corrupt/bad/files? a bad windows install perhaps and its just the only thing im noticing so far (as its all ive been doing?)

    could someone perhaps try that out just copy and paste it into a vb6 and run it? all u need is a command button listview textbox and Inet control....

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error "5"

    probably the line above it is incorrect and pos = 0 which will give an error when it tries to run

    check the value of pos at that line
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Re: Run Time Error "5"

    how do i check the pos? im still fairly new to vb6 and especially web apps

  7. #7
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Run Time Error "5"

    you can press ctrl + break for start debugging and in the immediate window type
    ?POS
    it will display the value of pos...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error "5"

    click in the feft margin so you get a red spot, the code will stop there when runniing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Re: Run Time Error "5"

    i did what u both said and it just stops at that part thats causing the problem i did notice though if i leave say Text1 in the "search" box sometimes when i press the command button it finds that theres nothing there what i mean is my message box pops up "no torrents found" which i find pretty odd why doesnt it do that everytime?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Re: Run Time Error "5"

    got it fixed guys i reinstalled vb6 and now its working it seems ill not mark this resolved just yet ill wait until im sure

  11. #11
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Run Time Error "5"

    Ally01, this is the project I mentioned in my PM message.
    Attached Files Attached Files

  12. #12

    Re: Run Time Error "5"

    You should have set up partitions when you had the chance, which is when you install Windows XP (it lets you use ghost without a disk so you don't have to reformat either)

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    120

    Re: Run Time Error "5"

    thanks to everyone for their help i got it working seemed to be a bad vb6 install once i reinstalled it worked perfect again without changing anything

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