|
-
Feb 8th, 2006, 08:26 PM
#1
Thread Starter
Addicted Member
Need some help
I have set up a small program which is basically the tutorial with some things changed so i can move an image around and have it shown on the other form. I can work it fine if its on the same computer but thats it, i cannot get it on another computer in or out of my network.
this is my code for the listening form
---------------------------------------------------------------
Option Explicit
Private Sub cmdSend_Click()
' send data from the textbox
txtchat.Text = "Waiter " & txtchat.Text
Winsock.SendData txtchat.Text
DoEvents
' display the text, and clear the textbox
txtmain.Text = txtmain.Text & vbCrLf & txtchat.Text
txtchat.Text = ""
End Sub
Private Sub Form_Load()
' set up the socket to listen on port 10101
Winsock.LocalPort = 10101
Winsock.Listen
End Sub
Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
' reset the socket, and accept the new connection
Winsock.Close
Winsock.Accept RequestID
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' get the data and display it in the textbox
Winsock.GetData strData
txtmain.Text = ""
txtmain.Text = txtmain.Text & strData
txtmain.SelStart = Len(txtmain.Text)
Image2.Left = txtmain.Text
End Sub
-----------------------------------------------------
and my other form
--------------------------------------------------------
Option Explicit
Dim saLia As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyRight Then
Image1.Left = Image1.Left + 100
End If
End Sub
Private Sub Form_Load()
' set up the winsock to connect to the local computer
Winsock.RemoteHost = "127.0.0.1"
Winsock.RemotePort = 10101
Winsock.Connect
saLia = 1
End Sub
Private Sub cmdSend_Click()
' send the data thats in the text box and
' clear it to prepare for the next chat message
txtchat.Text = "Connecter " & txtchat.Text
Winsock.SendData txtchat.Text
DoEvents
txtmain.Text = txtmain.Text & vbCrLf & txtchat.Text
txtchat.Text = ""
End Sub
Private Sub Timer1_Timer()
txtchat.Text = Image1.Left
Winsock.SendData txtchat.Text
DoEvents
txtmain.Text = txtmain.Text & vbCrLf & txtchat.Text
txtchat.Text = ""
End Sub
Private Sub Winsock_Connect()
' we are connected!
MsgBox "Connected"
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
' get the data from the socket
Winsock.GetData strData
' display it in the textbox
txtmain.Text = txtmain.Text & vbCrLf & strData
' scroll the box down
txtmain.SelStart = Len(txtmain.Text)
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, CancelDisplay As Boolean)
' an error has occured somewhere, so let the user know
MsgBox "Error: " & Description
' close the socket, ready to go again
End Sub
----------------------------------------------------------------
Please help me,, i've been trying to do this for a while now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|