Solved

Verry advanced string manipulation in VB 5 for chat program.

Posted on 2002-05-12
8
176 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 18

Expert Comment

by:mdougan
Comment Utility
Well, maybe if you explain the approach that you've taken, we can offer suggestions.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:eraser3
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now