Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Sorc.Polgara on September 28, 2004, 03:16 PM

Title: Rich textboxes and listboxes
Post by: Sorc.Polgara on September 28, 2004, 03:16 PM
I'm trying too run on the same form a listbox and a rich textbox.  the rich textbox is for chat and the listbox for displaying the packets recieved.

Like 4 out of 5 times vb6 crashes.  sometimes a memory error message appears but sometimes it doesn't

The list items are being added to the list I assume pretty fast because when I recieve a packet it has to add a new list item for each line of the debugged packet (using DebugOutput).  And almost at the same time I am adding like something to the rtb.

I run the program in vb and I click on "connect" so then it starts...

It adds like the first couple of things to the rtb and like to packets worth in the debugging list box.  But then the program, visual basic, crashes.

Are packets being recieved too fast to be able to add everything to the listbox? is something wrong with running the rtb and the lst at the same time?
Title: Re: Rich textboxes and listboxes
Post by: LordNevar on September 28, 2004, 03:41 PM
Are you parsing the text to the RTB, and the LSTBox seperately or together in the same function?
Title: Re: Rich textboxes and listboxes
Post by: Grok on September 28, 2004, 03:52 PM
Quote from: bethra on September 28, 2004, 03:16 PM
I'm trying too run on the same form a listbox and a rich textbox.  the rich textbox is for chat and the listbox for displaying the packets recieved.

Like 4 out of 5 times vb6 crashes.  sometimes a memory error message appears but sometimes it doesn't

The list items are being added to the list I assume pretty fast because when I recieve a packet it has to add a new list item for each line of the debugged packet (using DebugOutput).  And almost at the same time I am adding like something to the rtb.

I run the program in vb and I click on "connect" so then it starts...

It adds like the first couple of things to the rtb and like to packets worth in the debugging list box.  But then the program, visual basic, crashes.

Are packets being recieved too fast to be able to add everything to the listbox? is something wrong with running the rtb and the lst at the same time?

Provide a link to your source code, or some snippets of enough source that someone can help you.

Chances are high that your code is buggy.
Title: Re: Rich textboxes and listboxes
Post by: Sorc.Polgara on September 28, 2004, 04:44 PM
ok, the rtb isn't the problem.  removed the rtb and everything associated with it in the project.  I ran it and it still crashes so it must be the listbox.   The bot connects to bnet successfully... just crashes most of the time when I "connect".  Usually the first time I try it runs fine and I connect to bnet. but like if I do it again it crashes vb.

here is some code

Select Case IdentifyPacket(recvData)
    'sid_auth_info
    Case &H50
        TempPacket.ArraySize 3
        'debuffer the 0x50 packet that was recieved
        DArray() = GetBNCS.SID_AUTH_INFO(recvData)
               
        ServerToken = DArray(2)         'server token
               
        'send the 0x0d packet with the NLS revision
        sckBNLS.SendData SendBNLS.Packet0x0D(DArray(1))
               
        'send the 0x09 packet w/ the ProductID, Version, Checksum
        sckBNLS.SendData SendBNLS.Packet0x09(&H7, DArray(5), DArray(6))
   
        .lstDebug.AddItem "SID_AUTH_INFO:  Successful!"
        ListDebugOutput recvData, lstDebug, "[RECV]   SID_AUTH_INFO", Len(recvData)
           
    'sid_auth_check
    Case &H51
        DArray() = GetBNCS.SID_AUTH_CHECK(recvData)
               
        If DArray(1) = DWORDY(&H0) Then
            'send packet 0x02
            sckBNLS.SendData SendBNLS.Packet0x02

            'display status
            lstDebug.AddItem "SID_AUTH_CHECK:  Successful!"
        Else
            lstDebug.AddItem "SID_AUTH_CHECK:  Failure!"
        End If
               
        'Display recieved packet 0x51
        ListDebugOutput recvData, lstDebug, "[RECV]   SID_AUTH_CHECK", Len(recvData)


This code comes from the sckBNCS_DataArrival, winsock event.  When I recieve a BNCS packet I get its packet ID which I use in a Select Case.  I do the same for the sckBNLS_DataArrival, winsock event.

The list box that I am using to display the recieved packets is lstDebug.
The function "ListDebugOutput" is

Public Function ListDebugOutput(ByVal sIn As String, ListOut As ListBox, OutCaption$, Optional pSize As Long)
With ListOut
    Dim sOutArray() As String
    Dim sOut$
   
    sOut = DebugOutput(sIn)
    sOutArray = Split(sOut, vbNewLine)
    .AddItem ""
    .AddItem OutCaption & Space(3) & "Size: " & pSize
    .AddItem "--------------------------------------------------"
   
    For i = 0 To UBound(sOutArray)
        .AddItem sOutArray(i)
    Next

End With
End Function

DebugOutput is Grok's function that I am using (thanks grok)
Title: Re: Rich textboxes and listboxes
Post by: Sorc.Polgara on September 30, 2004, 02:49 PM
Ok.. I figured out the problem, it had nothing to do with the listbox or rtbs.  I guess I had jumped on them first since only a few lines of text appeared before it crashed.

I fixed the problem, it was a MemCopy statment.

Don't get me wrong, the program worked, it just happened that every so often this statement fudged me.

Close please.

Thanks guys for your time.  (reading this) =)

l8ter


edit:  oooooops sorry for the double post too!
Title: Re: Rich textboxes and listboxes
Post by: YaYYo on October 05, 2004, 07:02 AM
is this the part where you put the packets in the text bot to recieve what was typed?
Title: Re: Rich textboxes and listboxes
Post by: Meh on October 05, 2004, 10:38 AM
He wanted to send a chat mesage and when he recieved the packet back from the server it would add itself to a list, a bit like a packet logger.