Results 1 to 10 of 10

Thread: error 9 runtime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Unhappy error 9 runtime

    i created a script like this

    VB Code:
    1. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
    2. Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    3.     Dim lngRetVal As Long
    4.     lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    5.     If lngRetVal = 0 Then DownloadFile = True
    6. End Function
    7.  
    8. Private Sub Command1_Click()
    9. Open Environ("appdata") & "\unlimited\gegevens.dat" For Input As #6
    10. filedata = Input(LOF(6), #6)
    11. Close #6
    12. id = Split(filedata, "[id]")(1)
    13. subid = Split(filedata, "[subid]")(1)
    14. servergegevens = Inet1.OpenURL("http://www.davyquyo.com/progamma/getpas.asp?id=" & id & "&subid=" & subid)
    15. ip = Split(servergegevens, "||")(0)
    16. pas = Split(servergegevens, "||")(1)
    17. If pas <> "ultdclan" Then
    18. If MsgBox("the password of the server is changed, they are probebly in war right now. do you still want to proceed", vbYesNo, "in war") = vbNo Then
    19. Exit Sub
    20. End If
    21. End If
    22. If Len(Dir$(Environ("systemroot") & "\cod.ini")) = 0 Then
    23. MsgBox "you must have call of duty installed to proceed", vbCritical, "call of duty not found"
    24. Unload Form1
    25. End If
    26. Open Environ("systemroot") & "\cod.ini" For Input As #3
    27. codfile = Input(LOF(3), #3)
    28. Close #3
    29. lijnen = Split(codfile, vbNewLine)
    30. For i = 0 To UBound(lijnen) - 1
    31. If InStr(1, lijnen(i), "codmp.exe", vbTextCompare) Then
    32. codurl = Split(lijnen(i), "=")(1)
    33. Exit For
    34. End If
    35. Next i
    36. goedurlcod = Split(codurl, "CoDMP.exe")(0)
    37. ChDir (goedurlcod)
    38. Shell ("CoDMP.exe +password " & pas & " +connect " & ip), vbNormalFocus
    39. End Sub
    40.  
    41. Private Sub Command2_Click()
    42. If Len(Dir$(Environ("systemroot") & "\cod.ini")) = 0 Then
    43. MsgBox "you must have call of duty installed to proceed", vbCritical, "call of duty not found"
    44. Unload Form1
    45. End If
    46. Open Environ("systemroot") & "\cod.ini" For Input As #3
    47. codfile = Input(LOF(3), #3)
    48. Close #3
    49. lijnen = Split(codfile, vbNewLine)
    50. For i = 0 To UBound(lijnen) - 1
    51. If InStr(1, lijnen(i), "codmp.exe", vbTextCompare) Then
    52. codurl = Split(lijnen(i), "=")(1)
    53. Exit For
    54. End If
    55. Next i
    56. goedurlcod = Split(codurl, "CoDMP.exe")(0)
    57. ChDir (goedurlcod)
    58. Shell ("CoDMP.exe"), vbNormalFocus
    59. End Sub
    60.  
    61. Private Sub Command3_Click()
    62. MsgBox "this program is created by davy quyo and is only used for unlimited clan members, so have fun and if any problems exist please mail at [email][email protected][/email]", vbInformation, "info"
    63. End Sub
    64.  
    65. Private Sub Form_Load()
    66. If Dir(Environ("appdata") & "\unlimited", vbDirectory) = "" Then
    67. MkDir (Environ("appdata") & "\unlimited")
    68. End If
    69. If Len(Dir$(Environ("appdata") & "\unlimited\gegevens.dat")) = 0 Then
    70. Form2.Show
    71. Unload Form1
    72. Else
    73. checkupdate = Inet1.OpenURL("www.davyquyo.be/download.txt")
    74. If checkupdate = "ja" Then
    75. DownloadFile "http://www.davyquyo.be/update.exe", Environ("appdata") & "\unlimited\update.exe"
    76. Shell (Environ("appdata") & "\unlimited\update.exe")
    77. Unload Form1
    78. End If
    79. Open Environ("appdata") & "\unlimited\gegevens.dat" For Input As #2
    80. filedata = Input(LOF(2), #2)
    81. Close #2
    82. id = Split(filedata, "[id]")(1)
    83. subid = Split(filedata, "[subid]")(1)
    84. nicknaam = Inet1.OpenURL("http://www.davyquyo.com/progamma/getnick.asp?id=" & id & "&subid=" & subid)
    85. If nicknaam = "fout" Then
    86. MsgBox "an error showd up with your data please login again", vbCritical, "data error"
    87. Form2.Show
    88. Unload Form1
    89. End If
    90. If nicknaam = "nomember" Then
    91. MsgBox "it seems you are not a member anymore so you will not be able to use this program again", vbCritical, "data error"
    92. Unload Form1
    93. End If
    94. Call findcod(nicknaam)
    95. End If
    96. End Sub
    97. Private Function findcod(nicknaam)
    98. If Len(Dir$(Environ("systemroot") & "\cod.ini")) = 0 Then
    99. MsgBox "you must have call of duty installed to proceed", vbCritical, "call of duty not found"
    100. Unload Form1
    101. End If
    102. Open Environ("systemroot") & "\cod.ini" For Input As #3
    103. codfile = Input(LOF(3), #3)
    104. Close #3
    105. lijnen = Split(codfile, vbNewLine)
    106. For i = 0 To UBound(lijnen) - 1
    107. If InStr(1, lijnen(i), "codmp.exe", vbTextCompare) Then
    108. codurl = Split(lijnen(i), "=")(1)
    109. Exit For
    110. End If
    111. Next i
    112. goedurlcod = Split(codurl, "\CoDMP.exe")(0)
    113. Call setnick(nicknaam, goedurlcod)
    114. End Function
    115. Private Function setnick(nicknaam, cod)
    116. nick = Split(nicknaam, "||")(0)
    117. rang = Split(nicknaam, "||")(1)
    118. kleur0 = Replace(nick, "^0", "")
    119. kleur1 = Replace(kleur0, "^1", "")
    120. kleur2 = Replace(kleur1, "^2", "")
    121. kleur3 = Replace(kleur2, "^3", "")
    122. kleur4 = Replace(kleur3, "^4", "")
    123. kleur5 = Replace(kleur4, "^5", "")
    124. kleur6 = Replace(kleur5, "^6", "")
    125. kleur7 = Replace(kleur6, "^7", "")
    126. kleur8 = Replace(kleur7, "^8", "")
    127. g_nick = Replace(kleur8, "^9", "")
    128. ultdtag = "^7#^1ULTD^7|^4" & g_nick
    129. If rang = "1" Then
    130. current_nick = ultdtag & "^7-"
    131. Else
    132. If rang = "2" Then
    133. current_nick = ultdtag & "^7="
    134. Else
    135. MsgBox "error with nick, please contact clanleader", vbCritical, "wrong nick"
    136. Unload Form1
    137. End If
    138. End If
    139. Open cod & "\main\config_mp.cfg" For Input As #4
    140. nickcfg = Input(LOF(4), #4)
    141. Close #4
    142. splitnickcfg = Split(nickcfg, Chr(10))
    143. For i = 0 To UBound(splitnickcfg) - 1
    144. If InStr(1, splitnickcfg(i), "seta name", vbTextCompare) Then
    145. oudenick = Split(splitnickcfg(i), Chr(34))(1)
    146. Exit For
    147. End If
    148. Next i
    149. nieuw_bestand = Replace(nickcfg, oudenick, current_nick)
    150. Open cod & "\main\config_mp.cfg" For Output As #5
    151. Print #5, nieuw_bestand
    152. Close #5
    153. End Function


    form 2 is this

    VB Code:
    1. Private Sub Command1_Click()
    2. Text1.Text = ""
    3. Text2.Text = ""
    4. End Sub
    5.  
    6. Private Sub Command2_Click()
    7. checkgegevens = Inet1.OpenURL("http://www.davyquyo.com/progamma/login.asp?gebruikersnaam=" & Text1.Text & "&paswoord=" & Text2.Text)
    8. If checkgegevens = "fout" Then
    9. MsgBox "your data could not been found in our database", vbCritical, "wrong username/password"
    10. Else
    11. id = Split(checkgegevens, "||")(0)
    12. subid = Split(checkgegevens, "||")(1)
    13. Open Environ("appdata") & "\unlimited\gegevens.dat" For Output As #1
    14. Print #1, "[id]" & id & "[id]"
    15. Print #1, "[subid]" & subid & "[subid]"
    16. Close #1
    17. Form1.Show
    18. Unload Form2
    19. End If
    20. End Sub
    on my pc evrything goes perfect but but there are some users that get's an error

    error 9 run-time
    subject

    the error is not complete because he don't get it anymore it is just not reacting anymore can someone help me please

  2. #2
    Lively Member
    Join Date
    Jan 2003
    Posts
    79

    Re: error 9 runtime

    Error 9 is a "Subscript out of range" error which means that you have tried to reference either an array element in an empty array or an element index that is greater than the Ubound limit of the array.
    You need to put some error trapping into your code.

    All the best,

    Dave.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: error 9 runtime

    the program works perfect with so many users why does it not work with these 2
    the load script is executed completly i'm sure of that
    but the does not show form1

  4. #4

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: error 9 runtime

    i found the problem

    it seems that the form was show outside his screen
    how can i lock the settings so even how big his screeen his it's always in the right upper corner

  6. #6

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: error 9 runtime

    Marty's code does top left. This code does top right. Take your pick.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Move Screen.Width - Width, 0
    5. End Sub
    This world is not my home. I'm just passing through.

  8. #8

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: error 9 runtime

    Move (Screen.Width) - Width, 750
    Move (Screen.Height) + 750

    for me this is the exact location but is this good for every screen or not

  10. #10
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: error 9 runtime

    If you use a literal value of 750 then your form will always be displayed this number of units (not sure if they're pixels or twips or what - doesn't matter) from the top of the screen. Depending on the screen resolution this value will be a different proportion of the screen height. I don't think the physical dimensions of the screen make any difference - it is only the screen resolution that matters. You will be able to test your code by changing your screen resolution from the Control Panel.

    You may be better off deciding what fraction of the screen height you want the offset to be and then coding like this.


    VB Code:
    1. ' Place form 5% of the way down the screen.
    2. Move Screen.Width - Width, Screen.Height * ( 5 / 100 )
    This world is not my home. I'm just passing through.

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