Valhalla Legends Forums Archive | Visual Basic Programming | Error Loading File

AuthorMessageTime
Dyndrilliac
Ok, i'm working on a system for loading cheat files into my program and I get a subscript out of range error. Here's the relevant code:[code]Public Sub LoadCheats(File As String)
    If File = vbNullString Then
        Exit Sub
    End If

    On Error GoTo ErrHandler

    Dim pfNum  As Integer
    Dim I      As Integer
    Dim sInput As String
    Dim Tmp    As String
   
    Dim Splt() As String
   
    ReDim CheatBuffer(1000)
    CheatBuffer(0) = vbNullString
   
    pfNum = FreeFile
    I = 0
   
    Open (File) For Input As #pfNum
        Do Until EOF(pfNum)
            Input #pfNum, sInput
            CheatBuffer(I) = (sInput)
            I = I + 1
        Loop
    Close #pfNum
   
    For I = 0 To UBound(CheatBuffer)
        Splt() = Split(CheatBuffer(I), "|")
        frmMemPatch.lsvCheats.ListItems.Add , , Splt(1)
        Tmp = Splt(2)
        Splt(2) = "&H" & Tmp
        frmMemPatch.Engine.MemPatch Splt(2), Splt(3)
    Next I

    Exit Sub[/code]

Now, it errors on "frmMemPatch.Engine.MemPatch Splt(2), Splt(3)".  The content of the file I'm trying to load is:[quote]Score Doesn't Change|10030b8|909090[/quote]

"Score Doesn't Change" is the cheat name, 10030b8 is the address, and the 909090 is the data I'm placing there (3 nop instructions).

Any help in fixing this would be appreciated, and if you need to examine another part of the code just ask.
September 26, 2004, 11:41 PM
UserLoser.
[code]
Score Doesn't Change|10030b8|909090
[/code]

Splt(0) -> Score Doesn't Change
Splt(1) -> 10030b8
Splt(2) -> 909090
Splt(3) -> <Non-existant>
September 26, 2004, 11:44 PM
Dyndrilliac
Edit: Nvm, Figured it out. I needed a check for if Cheatbuffer(I) was a Null String before it split it.
September 27, 2004, 12:55 AM

Search