|
-
Nov 7th, 2000, 10:24 PM
#1
Thread Starter
Addicted Member
I have been studying Winsock controls.
I have recently been checking out the tutorial from the following site:
http://orion.spaceports.com/~mccloud...orial/3.2.html
Here is his coding... If I attempt to compile it, I get this error:
"Compile error- Sub or Function not defined"
Code:
Option Explicit
'Declares
Dim Logged As String
Dim Port As Long
Sub Log(iText As String)
'Add text
Logged = Logged & iText & vbNewLine
'Update texbox
txtLog.Text = Logged
'Update scrolling
txtLog.SelStart = Len(Logged)
End Sub
Private Sub mnuExit_Click()
Unload Me
End Sub
Sub Send(iText As String)
If WS.State = sckConnected Then
'Socket is connected
WS.SendData iText & "¶"
Log "You said: " & iText
Else
'...you know
Log "[Not connected]"
End If
End Sub
Private Sub txtText_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
'This clears the buffer since we
'dont really want the user to send
KeyAscii = 0
'Send the text
Send txtText.Text
'...and clear the box
txtText.Text = ""
End If
End Sub
Private Sub WS_Close()
WS.Close
Log "[Disconnected (Remote closed)]"
End Sub
Private Sub WS_ConnectionRequest(ByVal requestID As Long)
'Accept the connection
WS.Close
WS.Accept requestID
End Sub
Private Sub WS_Connect()
Log "[Connected to " & WS.RemoteHost & "]"
End Sub
Private Sub WS_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)
WS.Close
Log "[Disconnected (Error: " & Description & ")]"
End Sub
Private Sub mnuStartServer_Click()
'Wait for connection
WS.LocalPort = 12334
WS.Listen
Log "[Listening on port " & WS.LocalPort & "]"
End Sub
Private Sub mnuConnectTo_Click()
Static temp As String
'Get user input
temp = InputBox("Enter the IP (internet) or name (LAN) of the server computer)", _
"Connect to...", "127.0.0.1")
If Not temp = "" Then
'Connect to this computer
WS.Connect temp, 12334
Log "[Connecting to " & temp & "]"
End If
End Sub
Private Sub mnuDisconnect_Click()
WS.Close
Log "[Disconnected]"
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
Dim A As Long
Dim Data() As String
Dim temp As String
'Get the data from winsock
WS.GetData temp, vbString
'Split up in single messages
Data = Split(temp, "¶", , vbTextCompare)
'Go thru the messages
For A = 0 To UBound(Data, 1) - 1
Log "You hear: " & Data(A)
Next
End Sub
Private Sub Form_Resize()
On Error Resume Next
'Move the controls
txtLog.Move 0, 0, ScaleWidth, ScaleHeight - txtText.Height
txtText.Move 0, ScaleHeight - txtText.Height, ScaleWidth
End Sub
I have tried to add a definition but I continue to fail...
What do you think is the correction for this issue?
P.S. If you happen to know some great Winsock tutorials, please by all means enlighten me.
I appreciate all of your time and effort,
Daniel Christie
VB 5 and 6 Enterprise Editions,
Html, Java scipt, Vb script,
& etc...
http://www.qwcd.com
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
|