evet arkadaşlar şimdi 2 bilgisayar arasında winsock sayesinde chatı anlatacağım.
Yemeğimiz için malzemeler:
3 tane command button (1. si gönder butonu 2. si bağlan butonu diğeri Bağlantı bekle butonu)
Bir label hataların çıkması için
4 text (mesaj yazmak ip adresini yazmak ve nick yazmak için)
2 adet winsock (iletişim için) eklemek için Ctrl+T ye basın ve Microsoft Winsock Control 6.0 ı seçin
Not: Text 1 geçmiş Text 2 mesajını yaz Text 3 Nick Text 4 karşının ip adresi
kodlar Bunlar:
Option Explicit
Private Sub Command1_Click()
If Winsock1.State = 7 Then
Winsock1.SendData Text3.Text & " >> " & Text2.Text
Text1.Text = Text1.Text & Text3.Text & " >> " & Text2.Text & Chr(13) & Chr(10)
Text2.Text = ""
End If
End Sub
Private Sub Command2_Click()
If Winsock1.State = 2 Then
Command2.Caption = "Bağlan"
Else
Winsock1.RemoteHost = Text4.Text
Winsock1.RemotePort = 12345
Winsock1.Connect
Command2.Caption = "Bağlantıyı Kes"
End If
End Sub
Private Sub Command3_Click()
If Winsock1.State = 2 Then
Winsock1.Close
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
Else
Winsock1.LocalPort = 12345
Winsock1.Listen
Command3.Caption = "Bağlantıyı Kes"
Command2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
End If
End Sub
Private Sub Form_Load()
App.TaskVisible = False
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub
Private Sub winsock1_connectionrequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
Label1.Caption = "Bir bağlantı isteği geldi!"
Text2.Enabled = True
Command1.Enabled = True
End Sub
Private Sub winsock1_close()
Label1.Caption = "Bağlantı Kesildi!"
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
End Sub
Private Sub winsock1_connect()
Label4.Caption = "Bağlantı Sağlandı!"
Label1.Enabled = True
Command1.Enabled = True
Text3.Enabled = False
Text4.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim gelen As String
Winsock1.GetData gelen
Text1.Text = Text1.Text & gelen & Chr(13) & Chr(10)
End Sub
Private Sub winsock1_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)
Label4.Caption = "Hata Oluştu! Oluşan HATA : " & description
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
End Sub
ve EN ÖNEMLİ KISIM YEMEĞİMİZİ KAYDETMEDEN ÖNCE SÜSLÜYORUZ , TUZUNU AYARLIYORUZ VE FIRINDA 200 DERECEDE PİŞİRİYORUZ
Yapamayanlar söylesin direkman koyayım formu
Evet bide ip adresinizi nasıl öğreniceksiniz bilmeyenler için:
yeni bir form açın 1 command buton koyun 1 winsock ekleyin
ve:
Private Sub Command1_Click()
ip = Winsock1.LocalIP
MsgBox ip
End Sub
Alıntıdır
Bu arada programı yaptım ama denemeye vaktim olmadı çalışamasa kızmayın:trl
Yemeğimiz için malzemeler:
3 tane command button (1. si gönder butonu 2. si bağlan butonu diğeri Bağlantı bekle butonu)
Bir label hataların çıkması için
4 text (mesaj yazmak ip adresini yazmak ve nick yazmak için)
2 adet winsock (iletişim için) eklemek için Ctrl+T ye basın ve Microsoft Winsock Control 6.0 ı seçin
Not: Text 1 geçmiş Text 2 mesajını yaz Text 3 Nick Text 4 karşının ip adresi
kodlar Bunlar:
Option Explicit
Private Sub Command1_Click()
If Winsock1.State = 7 Then
Winsock1.SendData Text3.Text & " >> " & Text2.Text
Text1.Text = Text1.Text & Text3.Text & " >> " & Text2.Text & Chr(13) & Chr(10)
Text2.Text = ""
End If
End Sub
Private Sub Command2_Click()
If Winsock1.State = 2 Then
Command2.Caption = "Bağlan"
Else
Winsock1.RemoteHost = Text4.Text
Winsock1.RemotePort = 12345
Winsock1.Connect
Command2.Caption = "Bağlantıyı Kes"
End If
End Sub
Private Sub Command3_Click()
If Winsock1.State = 2 Then
Winsock1.Close
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
Else
Winsock1.LocalPort = 12345
Winsock1.Listen
Command3.Caption = "Bağlantıyı Kes"
Command2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
End If
End Sub
Private Sub Form_Load()
App.TaskVisible = False
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub
Private Sub winsock1_connectionrequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
Label1.Caption = "Bir bağlantı isteği geldi!"
Text2.Enabled = True
Command1.Enabled = True
End Sub
Private Sub winsock1_close()
Label1.Caption = "Bağlantı Kesildi!"
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
End Sub
Private Sub winsock1_connect()
Label4.Caption = "Bağlantı Sağlandı!"
Label1.Enabled = True
Command1.Enabled = True
Text3.Enabled = False
Text4.Enabled = False
Command3.Enabled = False
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim gelen As String
Winsock1.GetData gelen
Text1.Text = Text1.Text & gelen & Chr(13) & Chr(10)
End Sub
Private Sub winsock1_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)
Label4.Caption = "Hata Oluştu! Oluşan HATA : " & description
Command3.Caption = "Server KUR"
Command2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text2.Enabled = False
Command1.Enabled = False
End Sub
ve EN ÖNEMLİ KISIM YEMEĞİMİZİ KAYDETMEDEN ÖNCE SÜSLÜYORUZ , TUZUNU AYARLIYORUZ VE FIRINDA 200 DERECEDE PİŞİRİYORUZ
Yapamayanlar söylesin direkman koyayım formu
Evet bide ip adresinizi nasıl öğreniceksiniz bilmeyenler için:
yeni bir form açın 1 command buton koyun 1 winsock ekleyin
ve:
Private Sub Command1_Click()
ip = Winsock1.LocalIP
MsgBox ip
End Sub
Alıntıdır
Bu arada programı yaptım ama denemeye vaktim olmadı çalışamasa kızmayın:trl