Quick VB6 Split String help

Associate
Joined
1 Mar 2006
Posts
425
hi Guys


string is:

":USERNAME![email protected] PRIVMSG #Channel :Hello World"



i need to split the string to show

USERNAME:Hello World


im currently using the below


Dim Msg As String
Msg = Split(Data, " PRIVMSG " & Channel & " :")(1)

which returns

USERNAME:

and no hello world what am i doing wrong here? ive done this a million times in the past :confused:
 
I tested the code you have there and it returned 'Hello world' - not username, as you're setting msg = to the second element of the array.

Anway, here's something which should hopefully work for you. I've tested it using ASP/VBScript, but should be simple enough to translate to VB6.

Code:
<%
	data = ":[email protected] PRIVMSG #Channel :Hello World"
	
	values = split(data, ":")
	label = split(values(1), "!")(0)
	
	response.write(label & ":" & values(ubound(values)))
%>
 
thanks for that

the string is coming through a socket from a IRC server

i thought about


Code:
Dim Msg As String

Dim Msg2 As string

Dim msg3 as string

 

Msg = Split(Data, " PRIVMSG " & Channel & " :")(1) ‘ which gives you “USERNAME”

 

Msg2 = Split(Data, " PRIVMSG " & Channel & " :")(2) ‘ which should give you “:hello world”

 

 

Then concentrate msg and msg2 into msg3 dimension? To get USERNAME:hello world

 

Text1.text = (msg3) ‘ show concentrated string in textbox


Or is that just rubbish
 
Assuming the data is the same as your OP...

Code:
Msg = Split(Data, " PRIVMSG " & Channel & " :")(1)
... will give you 'USERNAME![email protected]'

Code:
Msg2 = Split(Data, " PRIVMSG " & Channel & " :")(2)
... will give you 'Hello World'

.: You'd get 'USERNAME![email protected]:Hello World'. Is this what you want?

Try the code I posted before, it gives exactly the result you wanted in your OP.
 
Back
Top Bottom