Results 1 to 4 of 4

Thread: Ok, I would appreciate some feedback about...

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    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

  2. #2
    New Member
    Join Date
    Sep 2000
    Location
    Kingston, Ontario, Canada
    Posts
    12
    It's the dim statements at the beginning.
    Dim statements are used to declare temporary variables on a procedure scope. You need to change the "dim" to "private".
    Hope this helps

  3. #3
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373

    Unhappy Sorry...

    Hi,

    I just tested and besides the missing textboxes and winsock
    control that i on porpouse didn't insert prior testing it to
    get all possible errrors i was able to run the app successfully.

    Maybe is the version of the Winsock, because i have VB6
    without any service pack and had no problems.

    hope that this info will help you.
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

  4. #4

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Flaming_Monkey

    Flaming_Monkey,

    Nope go fish!,

    when I use "Private", I get the following error:
    "Compile error- Invalid attribute in Sub or Function".

    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
  •  



Click Here to Expand Forum to Full Width