Verry advanced string manipulation in VB 5 for chat program.

Posted on 2002-05-12
Last Modified: 2013-11-13
I have been doing this for a week and a bit now, now i think it is time i asked for help ;-)

I have a server basically yuo connect to it and use it like you do an IRC server.  Now i got the communication working perfectly now to decipher this endless text.

This is a quick look at the kind of text that is being processed:


This is where you copme back and email me going what the hell is all that... But i will make it simple...
there is one main text box (the chat window) and 2 list boxes (1 for the normal members and one for the higher members).

Now all messages starting with 40| are to be displayed in the main window.

35| message is a massive clutter of the current people connected to the server, the numbers following are a jumbled ip address (enables the option of banning people off the server) these people will need to be sorted and have those numbers associated with them ppl with 0's before their name are normal like "0eraser" go in the first list box and people with anythign above 0 are better they go into the other listbox.

Messages starting with 31| and 21| are messages sent by users these are to be displayed in the main window. Again we need to get rid of that ip junk with the message but we still need to see who it is from.

That is basically it.
I have built a Java client for the chat and if you think it will help you code this i will email you the 4 files to you.

P.S I cant recall but if i remember right you cant put more on a certain amount of points on a question well if that is still the case i will make a fake question containing more points (of corse this is dependent on how it works.

P.P.S Changing the server is not an option.
Question by:eraser3

Author Comment

ID: 7005178
Sorry for some reason the normal text box copy didnt come out but not to worry im hopeing on using a rich text box.
also the data is comming via a winsock for e.g:
TCP1 = renamed winsock controll
Private Sub TCP1_DataArrival(ByVal bytesTotal As Long)
Dim inData As String
TCP1.GetData inData, vbString
End Sub
LVL 18

Expert Comment

ID: 7006080
You might try posting this on, this forum (EE) is best used to help people work through a problem on their own, rather than to farm out some coding to them.

Author Comment

ID: 7006126
Yeah you see i have done some code and it sort of works i was just wanting to see how other ppl would work through the problem.

Btw if someone answers this question they can have 5000 points

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

LVL 18

Expert Comment

ID: 7006627
Well, maybe if you explain the approach that you've taken, we can offer suggestions.

Author Comment

ID: 7008450
Ok at moment i have mocked up a crappy thing as follows:
This is just a quick thing for e.g it isnt online i just had a rich text box that i put the test data in, then i hit a button:

Incoming = test data (rich text box)
incoming2 = main chat window (rich text box)
user = list of users (rich text box soon to be list box)

Private Sub Command1_Click()
On Error GoTo error
Dim A40 As Variant
Dim A35 As Variant
Dim auser As Variant
Dim ausernew As Variant
Dim billy As String
usrname = eraser
delem = "|"
A40 = Parse(Incoming.Text, "|")
For v = 1 To UBound(A40)
'MsgBox (A40(v))
A35 = Right(A40(v), 3)
'MsgBox (A35)
Select Case A35
    Case 11
    MsgBox ("case11")
    Case 10
    MsgBox ("case10")
    Incoming2.Text = Incoming2.Text + "Name not unique, try a different name."
    Case 21
    Incoming2.Text = Incoming2.Text + usrname + A40(v + 1)
    Case 31
    'MsgBox ("case31")
    Incoming2.Text = Incoming2.Text + usrname + A40(v + 1) + A40(v + 2)
    Case 35
    'MsgBox ("case35")
    user.Text = ""
    user.Text = s1 + Chr(13) + A40(v + 1)
    'cse35 = Parse(Incoming, "40|1")
    Case 40
    'MsgBox ("case40 contains")
    Incoming2.Text = Incoming2.Text + "***" + A40(v + 1) + Chr(13)
    Case 70
    MsgBox ("case70")
    Case Else
    A35 = A35
End Select
Exit Sub
End Sub

Module parse:

Option Explicit
Public Function Parse(sIn As String, sDel As String) As Variant
    Dim i As Integer, x As Integer, s As Integer, t As Integer
    i = 1: s = 1: t = 1: x = 1
    ReDim tArr(1 To x) As Variant ''

    If InStr(1, sIn, sDel) <> 0 Then

            ReDim Preserve tArr(1 To x) As Variant
            tArr(i) = Mid(sIn, t, InStr(s, sIn, sDel) - t)
            t = InStr(s, sIn, sDel) + Len(sDel)
            s = t
            If tArr(i) <> "" Then i = i + 1
            x = x + 1
        Loop Until InStr(s, sIn, sDel) = 0
        ReDim Preserve tArr(1 To x) As Variant
        tArr(i) = Mid(sIn, t, Len(sIn) - t + 1)
        tArr(1) = sIn
    End If
    Parse = tArr
End Function '

I have been trying to emulate what a java code is doing but it is really hard to try and find an equal of alot of the syntax.

oh well hope you can help me... if your wondering what the +1 is for A40 as it seems to screw around getting the strings.

Thanks again
LVL 45

Expert Comment

ID: 7008790
Maybe this will help:
1. parse the entire string by lines (vbcrlf-, vbcr-, or vblf-delimited)
2. parse the lines on the first "|" character
strCode = Left$(strLines(x),InStr(strLines(x), "|")-1)
3. base further action (parsing and placement) on the code.
LVL 49

Expert Comment

ID: 7765267
Hi eraser3,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

eraser3, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
DanRollins -- EE database cleanup volunteer

Accepted Solution

SpideyMod earned 0 total points
ID: 7834757
per recommendation

Community Support Moderator @Experts Exchange

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question