Visualizzazione dei risultati da 1 a 3 su 3

Discussione: [VB6] Winsock

  1. #1

    Visual Basic 6.0 Winsock

    Ciao.
    Cercando per il forum ho trovato una discussione dove parlava di winsock e come utilizzarle con Visual Basic, e c'era un link di un sito che spiegava come utilizzare le winsock Visual Basic fin qui tutto bene mi sono messo pian pian e me lo sono letto tutto oltre tutto in inglese.
    Il problema e che l'esempio principale non mi funziona mi da un errore
    dicendomi che le variabili non sono state definite.
    Mi dimenticavo sto usando Visual Basic 6.0 ho provato in tutti i modi
    ma non ci riesco vi posto il codice se qualcuno potrebbe darmi una dritta ne sarei veramente contento grazie per ogni suggerimento
    ---------------------------------------------------------------------
    ' in your first program, we need to listen for a
    ' connection. Add the winsock control to your project by clicking on
    ' "Project"-->"Components". Scroll down to find the "Microsoft Winsock
    ' Control 6". Check the box, then click OK. Draw an control onto the form,
    ' call it "Winsock", and then paste this code into the form.

    Private Sub Form_Load()
    Winsock.LocalPort = 10101
    Winsock.Listen
    End Sub

    Private Sub Winsock_ConnectionRequest(ByVal RequestID As Long)
    Winsock.Close
    Winsock.Accept RequestID
    End Sub

    ' in your Second program, we need to make an outgoing
    ' connection. So, follow the same procedure as above, and
    ' draw a Winsock onto the form, calling it "Winsock"
    ' Also, draw a command button on, and call it "cmdConnect"

    Private Sub cmdConnect_Click()
    Winsock.RemoteHost = "127.0.0.1"
    Winsock.RemotePort = 10101
    Winsock.Connect
    End Sub

    Private Sub Winsock_Connect()
    MsgBox "Connected"
    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)
    MsgBox "Error: " & Description
    End Sub

    ' now run both programs within VB and press the command button.
    ' If all has gone to plan, you should get a msgbox saying "Connected"...
    --------------------------------------------------------------

  2. #2

    Visual basic 6.0

    Le variabile che mi da indefinite nel primo programma e Winsock.LocalPort nel secondo invece e Winsock.RemoteHost a
    aiutatemi anche se per voi vi puo sembrare facile per me e veramente difficile perche non capisco proprio dove sta l'errore grazie

  3. #3
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    ma siamo sicuri che all'oggetto winsocket che hai aggiunto nel tuo form gli hai dato il nome winsock ?
    Jupy

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.