LoRdKiFlEx
Messages postés24Date d'inscriptionvendredi 30 août 2002StatutMembreDernière intervention 1 octobre 2004
-
22 nov. 2002 à 19:50
Endemoniada
Messages postés1Date d'inscriptionvendredi 10 octobre 2003StatutMembreDernière intervention10 octobre 2003
-
10 oct. 2003 à 16:41
voila le code source de mon chat qui fait a la fois client et serveur
form1:
Private Sub Form_Load()
Text3.Enabled = False 'desactiver case IP
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then 'Si cocher (mod client )alors
Text3.Enabled = True 'case Ip activer
Else
Text3.Enabled = False 'sinon non
End If
End Sub
Private Sub Command1_Click()
Dim alert As StringIf Text1 "" Or Text2 "" Or Text3 = "" Then 'si une des case et vide alors...
alert = MsgBox("Remplissez toutes les cases", vbCritical, "ATTENTION !!!") 'message d'alert
Else 'sinon on passe a le fenetre de chat
Text2.Enabled = False
Text3.Enabled = False
Check1.Enabled = False
Me.Hide
Form2.Show
If Command1.Caption = "OK" Then
If Check1.Value = 0 Then
Form2.List1.AddItem Text1.Text
Else
Form2.Winsock(0).SendData "/logni" & Form2.Winsock(0).LocalIP & " a changé de pseudo à " & Time & ". Il s'appel maintenant " & Text1.Text
End If
Command1.Caption = "OK"
End If
End If
End Sub
form2 :
Public intmax As Integer
Public serveur As Boolean
Public client As Boolean
Public alert As String
Private Sub Form_Load()
serveur = False
client = False
If Form1.Check1.Value = 1 Then
client = True
Winsock(0).RemoteHost = Form1.Text2.Text
Winsock(0).RemotePort = Form1.Text3.Text
Winsock(0).Connect
List1.AddItem "-" & Form1.Text1.Text
Else
serveur = True
intmax = 0
Winsock(0).Close
Winsock(0).LocalPort = Form1.Text2.Text
Winsock(0).Listen
List1.AddItem "@" & Form1.Text1.Text
End If
RichTextBox1.SelText = Form1.Text1.Text & " , bienvenue sur Comunnix!"
End Sub
Private Sub winsock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
If serveur = True Then
If Index = 0 Then
intmax = intmax + 1
Load Winsock(intmax)
Winsock(intmax).LocalPort = Form1.Text2.Text
Winsock(intmax).Accept requestID
End If
End If
End Sub
Private Sub winsock_DataArrival(Index As Integer, ByVal bytesTotal As Long)
On Error Resume Next
Dim data As String
If serveur = True Then
Winsock(Index).GetData data
Select Case Left(data, 6)
Case "\logls"
Form3.List1.AddItem Right(data, Len(data) - 6)
Case "\logni"
List1.AddItem "-" & Right(data, Len(data) - 6)
Case Else
RichTextBox1.SelText = data
For i = 1 To intmax
If Winsock(i).State = sckConnected Then
Winsock(i).SendData data
End If
Next
End Select
Else
Winsock(0).GetData data
RichTextBox1.SelText = data
End If
End Sub
Private Sub ok_Click()
crlf = Chr$(13) + Chr$(10)
If serveur = True Then
For i = 1 To intmax
If Winsock(i).State = sckConnected Then
Winsock(i).SendData crlf & "<" & Form1.Text1.Text & ">" & Text1.Text
End If
Next
RichTextBox1.SelText = crlf & "<" & Form1.Text1.Text & ">" & Text1.Text
Else
Winsock(0).SendData crlf & "<" & Form1.Text1.Text & ">" & Text1.Text
End If
Text1.Text = ""
End Sub
Private Sub Winsock_Connect(Index As Integer)
If Winsock(0).State <> sckConnected Then
RichTextBox1.SelText = "erreur impossible de se connecter au serveur, verifier si vous avez mis le bon port et/ou la bonne adresse!!!"
Else
RichTextBox1.SelText = "Connection reussit à l'adresse " & Form1.Text3.Text & "reussit"
Winsock(0).SendData "\logls" & Form1.Text1.Text & " (" & Winsock(0).LocalIP & ")" & " s'est connecté le " & Date & " à " & Time
End If
End Sub
Private Sub log_Click()
If serveur = True Then
Form3.Show
Else
alert = MsgBox("Vous n'avez pas accé au log des connection", vbCritical, "Accé refusé")
End If
End Sub
Private Sub quitter_Click()
End
End Sub
Private Sub conf_Click()
Form1.Show
End Sub
Private Sub form_unload(cancel As Integer)
Winsock(0).Close
Unload Form1
Unload Form3
Unload Me
End Sub
voila le code il n'y a pas de probleme pendant la compilation du prog ni quand il est en mode serveur mais en mod client il m'affiche :
Erreur d'execution '13':
type incompatible
savez vous pourkoi et comment resoudre ce probleme
kaitoq
Messages postés3Date d'inscriptionsamedi 23 août 2003StatutMembreDernière intervention24 août 2003 23 août 2003 à 13:40
Slt
C'est normal que tu n'est pas d'erreur a la compilation car ton probleme est la conversion de type or le compilateur verifie seulement si il connait les types que tu as cité.
je te conseille de regarder ou l'erreur est génerée en mode debugger et de verifier la concordance des types que tu veux attribué
Endemoniada
Messages postés1Date d'inscriptionvendredi 10 octobre 2003StatutMembreDernière intervention10 octobre 2003 10 oct. 2003 à 16:41
Un chat Multiuser ? une belle vérité de Lapalice ! rappelles-moi juste à quoi peut bien servir un chat MONO-user. Ca existe, on appelle ça un mirroir. Allez c'est juste pour rire :o)