Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - creare una chat in vb express edition 2008! aiuto!
Forum - Visual Basic 6 - creare una chat in vb express edition 2008! aiuto!

Avatar
nala84 (Normal User)
Newbie


Messaggi: 13
Iscritto: 18/03/2008

Segnala al moderatore
Postato alle 17:14
Martedì, 18/03/2008
Questo topic è stato chiuso dal moderatore

ciao a tutti!
sto provando a creare una chat utilizzando visual basic express edition 2008... ho provato ad eseguire le istruzioni site in tale sito:
http://www.vbasic.it/articoli/ldlChat.htm


quindi ho inserito nel mio progetto Client tale codice:

Public Class Form1

    Private Sub cmdConnetti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnetti.Click
        Static Stat As Boolean   ' Variabile statica che contiene True se si è connessi e False se non
        If Stat = False Then
            If Len(txtIP.Text) > 0 And Len(txtPorta.Text) > 0 Then ' Se c'è sia l'IP sia la porta
                TCP.Connect(txtIP, Val(txtPorta))                       ' Si connette
                cmdConnetti.Text = "Disconnetti"
                Stat = True
                lblStato.Text = "Connettendo"
            Else
                MsgBox("Dati mancanti!", vbExclamation)
            End If
        Else
            TCP.Close()                                                ' Chiude La connessione
            Stat = False
            lblStato.Text = "Chiudendo"
            cmdConnetti.Text = "Connetti"
        End If

    End Sub



    Private Sub TCP_ConnectEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCP.ConnectEvent
        lblStato.Text = "Connesso"
    End Sub
    Private Sub TCP_CloseEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles TCP.CloseEvent
        TCP.Close()      ' Per chiudere definitivamente la socket senno rimane .State = sckClosing
        lblStato.Text = "Disconnesso"
    End Sub

  

    Private Sub cmdInvia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInvia.Click
        If Len(txtInvia) > 0 Then      ' Se c'è qualcosa da spedire la spedisci
            TCP.SendData(txtInvia.Text)   ' Invia i dati
            txtChat.Text = txtChat.Text & "locale> " & txtInvia.Text & vbCrLf
            txtChat.SelectionStart= Len(txtChat.Text)
            txtInvia.Text = vbNullString
            lblStato.Text = "Inviando " & Len(txtInvia.Text) & "Bytes"
        End If

    End Sub

    Private Sub TCP_SendComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles TCP.SendComplete
        lblStato.Text = "Dati inviati con successo"

    End Sub
    Dim Description As String
    Dim Scode As Long
    Dim Source As String
    Dim HelpFile As String
    Dim HelpContext As Long
    Dim CancelDisplay As Boolean

    Private Sub TCP_Error(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ErrorEvent) Handles TCP.Error
        Dim Number As Integer

        TCP.Close()          ' Chiude la socket MsgBox "Errore TCP " & Number & vbCrLf & Description
        lblStato.Text = "Errore TCP " & Number
    End Sub

    Private Sub TCP_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles TCP.DataArrival
        Dim Data As String
        Dim bytesTotal As Long
        TCP.GetData(Data)  ' Copia i dati del Buffer in entrata nella variabile Data e svuota il Buffer
        lblStato.Text = "In arrivo " & bytesTotal & " bytes"
        txtChat.Text = txtChat.Text & "remoto> " & Data & vbCrLf     ' Aggiunge il Testo
        ' Imposta come inizio della selezione la fine, per lo scrolling automatico
        txtChat.SelectionStart = Len(txtChat.Text)
    End Sub
End Class

ma mi restituisce un avviso:
Variabile 'Data' passata per riferimento prima dell'assegnazione di un valore. È possibile che venga restituita un'eccezione dovuta a un riferimento con valore null in fase di esecuzione.    

e mandandolo in esecuzione, infatti, mi genera 2 eccezioni:
- la prima cliccando sul bottone "invia"
- la seconda cliccando sul bottone "Connetti"

Qlc sa come aiutarmi?? :(

PM
Avatar
P4p3r0g4 (Member)
Guru


Messaggi: 1319
Iscritto: 29/12/2006

Segnala al moderatore
Postato alle 17:31
Martedì, 18/03/2008
prova in .net (al quale vb 2008 appartine)
qua si tratta di vb6 che sopratutto in quanto a relazionarsi con l'esterno ha componenti totalnente differenti.

PM
Avatar
Shutdown (Founder Member)
Guru


Messaggi: 1212
Iscritto: 10/09/2005

Segnala al moderatore
Postato alle 21:31
Martedì, 18/03/2008
Esatto paperoga ha ragione!
Grazie pap! :love: :D

Topic locked.

PM