VB编一个聊天工具
如何用VB编一个聊天工具,至少要局域网的回答的人请不要到网上copy文章之类的代码,我看不懂只想知道如何做....如果可以请教我怎么做...事成之后再加150分!都说不要...
如何用VB编一个聊天工具,至少要局域网的
回答的人请不要到网上copy文章之类的代码,我看不懂
只想知道如何做....如果可以请教我怎么做...
事成之后再加150分!
都说不要到网上找那些文章了,看不懂有屁用啊 展开
回答的人请不要到网上copy文章之类的代码,我看不懂
只想知道如何做....如果可以请教我怎么做...
事成之后再加150分!
都说不要到网上找那些文章了,看不懂有屁用啊 展开
展开全部
怎么都要这个东西,那天也看到一个要代码的 那我就再贴一个。我调试过 没问题的 只要你对winsock控件了解 其实没什么的 就是一些对接收到的和发送的信息做一些处理而已 你先吧程序做好,慢慢再按照功能看,会比较简单。如果不行 我再给你源程序。给你讲解下也行
一个server端
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Winsockserver.SendData Text4.Text + ":" + textsend.Text
textget.Text = textget.Text + vbCrLf + Text4.Text + ":" + textsend.Text + " " + Str(Time)
textsend.Text = ""
End Sub
Private Sub Form_Load()
Command2.Visible = False
textsend.Visible = False
Text4.Visible = False
textget.Visible = False
Label1.Visible = False
Winsockserver.LocalPort = 1001
Winsockserver.Listen
End Sub
Private Sub textsend_Change()
'Winsockserver.SendData textsend.text
End Sub
Private Sub textsend_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'Winsockserver.SendData textsend.text
'textsend.text = ""
If KeyAscii = 13 Then
Winsockserver.SendData textsend.Text
' Text1.text = Text1.text + vbCrLf + Text4.text + ": " + Text2.text + " " + Str(Time)
textsend.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
If Text4.Text = "" Then Text4.Text = "no name"
End Sub
Private Sub Winsockserver_Close()
Winsockserver.Close
End
End Sub
Private Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
Command2.Visible = True
textsend.Visible = True
textget.Visible = True
Text4.Visible = True
Label1.Visible = True
If Winsockserver.State <> sckClosed Then Winsockserver.Close
Winsockserver.Accept requestID
End Sub
Private Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String
Winsockserver.GetData tmpstr
'textget.text = textget + tmpstr + textsend
textget.Text = textget.Text + vbCrLf + tmpstr + " " + Str(Time)
End Sub
'(1)Command1:退出按钮;
'(2)textsend:发送数据文本框;
'(3)Winsockserver: 服务器Winsock;
'(4)textget :接收数据文本框。
一个client端
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
On Error Resume Next
Winsockclient.RemoteHost = Text1.Text
Winsockclient.Connect
End Sub
Private Sub Command3_Click()
Winsockclient.SendData Text4.Text + ":" + textsend.Text
textget.Text = textget.Text + vbCrLf + Text4.Text + ":" + textsend.Text + " " + Str(Time)
textsend.Text = ""
End Sub
Private Sub Form_Load()
Command3.Visible = False
textsend.Visible = False
Text4.Visible = False
textget.Visible = False
Label2.Visible = False
Label3.Visible = False
Command2.Enabled = True
Winsockclient.RemoteHost = "192.168.1.211"
Winsockclient.RemotePort = 1001
Winsockclient.RemoteHost = "sccdsz"
End Sub
Private Sub Text1_Change()
Command2.Enabled = True
'Winsockclient.RemoteHost = Text1.Text
End Sub
Private Sub textsend_Change()
'Winsockclient.SendData textsend.Text
End Sub
Private Sub textsend_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'Winsockclient.SendData textsend.Text
'textsend.Text = ""
If KeyAscii = 13 Then
Winsockclient.SendData Text4.Text + ":" + textsend.Text
textsend.Text = ""
'End If
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Winsockclient.Connect
Winsockclient.RemoteHost = Text1.Text
End Sub
Private Sub Winsockclient_Close()
Winsockclient.Close
End
End Sub
Private Sub winsockclient_Connect()
textsend.Visible = True
textget.Visible = True
Label2.Visible = True
Label3.Visible = True
Text4.Visible = True
Command2.Enabled = True
Command2.Visible = True
Command3.Visible = True
End Sub
Private Sub winsockclient_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String
Winsockclient.GetData tmpstr
textget.Text = textget.Text + vbCrLf + tmpstr + " " + Str(Time)
End Sub
'(1)Command1:退出按钮;
'(2)Command2:连接按钮;
'(3)Winsockclient:客户Winsock;
'(4)Text1:主机名文本框;
'(5)Textsend:发送数据文本框;
'(6)Textget:接收数据文本框; 客户机程序的界面如图所示。
一个server端
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Winsockserver.SendData Text4.Text + ":" + textsend.Text
textget.Text = textget.Text + vbCrLf + Text4.Text + ":" + textsend.Text + " " + Str(Time)
textsend.Text = ""
End Sub
Private Sub Form_Load()
Command2.Visible = False
textsend.Visible = False
Text4.Visible = False
textget.Visible = False
Label1.Visible = False
Winsockserver.LocalPort = 1001
Winsockserver.Listen
End Sub
Private Sub textsend_Change()
'Winsockserver.SendData textsend.text
End Sub
Private Sub textsend_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'Winsockserver.SendData textsend.text
'textsend.text = ""
If KeyAscii = 13 Then
Winsockserver.SendData textsend.Text
' Text1.text = Text1.text + vbCrLf + Text4.text + ": " + Text2.text + " " + Str(Time)
textsend.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
If Text4.Text = "" Then Text4.Text = "no name"
End Sub
Private Sub Winsockserver_Close()
Winsockserver.Close
End
End Sub
Private Sub Winsockserver_ConnectionRequest(ByVal requestID As Long)
Command2.Visible = True
textsend.Visible = True
textget.Visible = True
Text4.Visible = True
Label1.Visible = True
If Winsockserver.State <> sckClosed Then Winsockserver.Close
Winsockserver.Accept requestID
End Sub
Private Sub Winsockserver_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String
Winsockserver.GetData tmpstr
'textget.text = textget + tmpstr + textsend
textget.Text = textget.Text + vbCrLf + tmpstr + " " + Str(Time)
End Sub
'(1)Command1:退出按钮;
'(2)textsend:发送数据文本框;
'(3)Winsockserver: 服务器Winsock;
'(4)textget :接收数据文本框。
一个client端
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
On Error Resume Next
Winsockclient.RemoteHost = Text1.Text
Winsockclient.Connect
End Sub
Private Sub Command3_Click()
Winsockclient.SendData Text4.Text + ":" + textsend.Text
textget.Text = textget.Text + vbCrLf + Text4.Text + ":" + textsend.Text + " " + Str(Time)
textsend.Text = ""
End Sub
Private Sub Form_Load()
Command3.Visible = False
textsend.Visible = False
Text4.Visible = False
textget.Visible = False
Label2.Visible = False
Label3.Visible = False
Command2.Enabled = True
Winsockclient.RemoteHost = "192.168.1.211"
Winsockclient.RemotePort = 1001
Winsockclient.RemoteHost = "sccdsz"
End Sub
Private Sub Text1_Change()
Command2.Enabled = True
'Winsockclient.RemoteHost = Text1.Text
End Sub
Private Sub textsend_Change()
'Winsockclient.SendData textsend.Text
End Sub
Private Sub textsend_KeyPress(KeyAscii As Integer)
'If KeyAscii = 13 Then
'Winsockclient.SendData textsend.Text
'textsend.Text = ""
If KeyAscii = 13 Then
Winsockclient.SendData Text4.Text + ":" + textsend.Text
textsend.Text = ""
'End If
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Winsockclient.Connect
Winsockclient.RemoteHost = Text1.Text
End Sub
Private Sub Winsockclient_Close()
Winsockclient.Close
End
End Sub
Private Sub winsockclient_Connect()
textsend.Visible = True
textget.Visible = True
Label2.Visible = True
Label3.Visible = True
Text4.Visible = True
Command2.Enabled = True
Command2.Visible = True
Command3.Visible = True
End Sub
Private Sub winsockclient_DataArrival(ByVal bytesTotal As Long)
Dim tmpstr As String
Winsockclient.GetData tmpstr
textget.Text = textget.Text + vbCrLf + tmpstr + " " + Str(Time)
End Sub
'(1)Command1:退出按钮;
'(2)Command2:连接按钮;
'(3)Winsockclient:客户Winsock;
'(4)Text1:主机名文本框;
'(5)Textsend:发送数据文本框;
'(6)Textget:接收数据文本框; 客户机程序的界面如图所示。
展开全部
使用Winsock控件,Winsock控件是VB5.0的新增功能,它解决了以往应用VB编程时网络中应用程序之间无法实现点对点通信的难题。Winsock使用的TCP协议和UDP协议允许建立并保持一个到远程计算机上的连接,且可以在连接结束之前实时地进行数据交换。用户仅通过设置属性并借助事件处理就能够轻而易举地连接到一个远程的计算机上,而且只用两个命令就可以实现数据交换。
具体使用方法和例子见网页:
http://www.xinlingtong.com/download/book/vbjq/internet/31.HTM
具体使用方法和例子见网页:
http://www.xinlingtong.com/download/book/vbjq/internet/31.HTM
参考资料: http://www.xinlingtong.com/download/book/vbjq/internet/31.HTM
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
那你至少要两个程序,一个做SERVER端,一个Client端。server端监听端口接收client端发来的请求,然后发送给相应的client端。
可以用winsock控件来做,TCP或者UDP协议都可以。
可以用winsock控件来做,TCP或者UDP协议都可以。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哎呀,我用VBS脚本做过一个基于网页的P2P聊天工具。
主体思路采用了Winsock编程。
不难的。
主体思路采用了Winsock编程。
不难的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
哈哈。。。我有一个非常简单的方法,两下搞定。
不过只能用于2000,XP,2003等系统的局域网,98的不能用。
不过只能用于2000,XP,2003等系统的局域网,98的不能用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询