Valhalla Legends Forums Archive | Visual Basic Programming | Rich textboxes and listboxes

AuthorMessageTime
bethra
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?
September 28, 2004, 8:16 PM
LordNevar
Are you parsing the text to the RTB, and the LSTBox seperately or together in the same function?
September 28, 2004, 8:41 PM
Grok
[quote author=bethra link=topic=8927.msg82471#msg82471 date=1096402566]
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?
[/quote]

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.
September 28, 2004, 8:52 PM
bethra
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
[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)
[/code]

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
[code]
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
[/code]
DebugOutput is Grok's function that I am using (thanks grok)
September 28, 2004, 9:44 PM
bethra
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!
September 30, 2004, 7:49 PM
YaYYo
is this the part where you put the packets in the text bot to recieve what was typed?
October 5, 2004, 12:02 PM
The-Rabid-Lord
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.
October 5, 2004, 3:38 PM

Search