View Full Version : Person to Person chat problem
__Yautja__
06-08-2004, 11:50 PM
Ok I'm really starting to get the hang of the VB6 coding stuff, I'm not a half bad programmer right now but I have ran into a problem. I can connect to computers together and Send messages to one another, I also use usernames for this chat program and stuff. When I send the data to the server and the server receives the data and displays it on the main chat textbox all the text is jumbled together. To make it clearer say my username is Roman.....and my message is hello. The server gets the data and displays it on the screen but it comes out like this.....RomanHello. How can I get it to where it show up like this......Roman: Hello? I know you have to use string processing and I have tried that but with no results. Can someone please help me? Thanks.
FiT-MiCkY
06-22-2004, 07:00 AM
I just threw this together and quickly tested it on myself, so just give it a try, if it doesn't work for you reply here or drop a PM in my private messages and I'll go over it again.
'#########################################
Private Sub Command1_Click
'Command1 = Send Message Button
'Text1 = Chatbox
'Text2 = Message
Chatname = InputBox("Enter Your Chatname Below:", "Chat Name", "")
If Chatname = "" Then
Chatname = "Anonymous"
End If
Text1.Text = Text1.Text & vbCrLf & Chatname & ": " & Text2.Text
Text1.SelStart = Len(Text1.Text)
'Adds The Message To Their Own Chatbox First
Winsock1.SendData "#MESSAGE:" & Chatname & ": " & Text2.Text
'Assuming They're Connected, It'll Send The Data
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim incoming As String
Winsock1.GetData incoming
Select Case InStr(1, incoming, "#MESSAGE:")
'If #MESSAGE: Comes Back Into The 'Incoming' Data Then.. 'Declarations
Dim ChatName As String
Case Is > 0
If Text1.Text = "" Then
Text1.Text = Text1.Text & Mid(incoming, 10)
Else
Text1.Text = Text1.Text & vbCrLf & Mid(incoming, 10)
End If
Text1.SelStart = Len(Text1.Text)
Exit Sub
Case Is > 0
End Select
End Sub
'#########################################
That's basically it, the best way to test it is to create duplicate Forms and connect to yourself. I don't know if you know how to do that, I'll type the code anyway just incase.
'#########################################
'Declarations
Dim NewForm As Form1
Private Sub Form_Click()
Set NewForm = New Form1
NewForm.Visible = True
MsgBox Winsock1.LocalIP, vbInformation Or vbOKOnly, "My IP Address"
End Sub
'#########################################
Hope this helped a little.
Fit-Micky
John-
06-22-2004, 08:46 AM
sorry to go off-topic in this thread but how are you mickey long time no see.
FiT-MiCkY
06-22-2004, 01:54 PM
Im 17 John, 18 later this year.
John-
06-22-2004, 05:20 PM
cool good to see you still come to some yahoo sites.
vBulletin v3.5.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.