Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Dyndrilliac on September 26, 2004, 06:41 PM

Title: Error Loading File
Post by: Dyndrilliac on September 26, 2004, 06:41 PM
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: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


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

"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.
Title: Re: Error Loading File
Post by: UserLoser. on September 26, 2004, 06:44 PM

Score Doesn't Change|10030b8|909090


Splt(0) -> Score Doesn't Change
Splt(1) -> 10030b8
Splt(2) -> 909090
Splt(3) -> <Non-existant>
Title: Re: Error Loading File
Post by: Dyndrilliac on September 26, 2004, 07:55 PM
Edit: Nvm, Figured it out. I needed a check for if Cheatbuffer(I) was a Null String before it split it.