@hotmail.com
@hotmail.com
我这里有一个在一台电脑上实现的聊天软件
代码是:
'
Private Sub Form_Load() '服务器代码
With udppeerA
.RemoteHost = "192.168.1.7" '修改为计算机的名字
.RemotePort = 1001 '连接的断口号
.Bind 1002 '绑定到本地断口
End With
formpeerA.Left = (Screen.Width + formpeerB.Width - formpeerA.Width) / 2
formpeerA.Top = (Screen.Height - formpeerA.Height) / 2
formpeerB.Top = formpeerA.Top
formpeerB.Left = formpeerA.Left - formpeerB.Width
formpeerB.Show '显示第二个窗体
End Sub
Private Sub Text1_Change()
udppeerA.SendData Text1.Text
End Sub
Private Sub udppeerA_dataArrival(ByVal bytesTotal As Long)
Dim strdata As String
udppeerA.GetData strdata
Text2.Text = strdata
End Sub
Private Sub Form_Load()
With udppeerB
.RemoteHost = "192.168.1.7"
.RemotePort = 1002
.Bind 1001
End With
End Sub
Private Sub Text1_Change()
udppeerB.SendData Text1.Text
End Sub
Private Sub udppeerB_DataArrival(ByVal bytesTotal As Long)
Dim strdata As String
udppeerB.GetData strdata
Text2.Text = strdata
End Sub
这里其实很简单 你只要改一下远程的IP地址就可以了
希望你能自己动手做做!!
另外的一个可以在两台电脑上实现 我发在你的邮箱里