Solved

Verry advanced string manipulation in VB 5 for chat program.

Posted on 2002-05-12
8
185 Views
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 ;-)

Background:
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:

http:\\members.iweb.net.au\~eraser3\chat.txt
http:\\members.iweb.net.au\~eraser3\chat2.txt

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.
0
Comment
Question by:eraser3
8 Comments
 

Author Comment

by:eraser3
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
0
 
LVL 18

Expert Comment

by:mdougan
ID: 7006080
You might try posting this on www.rent-a-coder.com, 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.
0
 

Author Comment

by:eraser3
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

later
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

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

Author Comment

by:eraser3
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
Next
error:
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


       Do
            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)
    Else
        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
-Marc
0
 
LVL 45

Expert Comment

by:aikimark
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.
0
 
LVL 49

Expert Comment

by:DanRollins
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
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7834757
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 115
Zip Folders Using Chilkat Routines 1 71
VB6 - Scroll Mouse wheel on Picturebox 13 93
VBA: copy range dynamically based on config sheet v2 3 55
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

679 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