主题:高手帮忙写个程序```
做个聊天程序
一个 客服端 一个服务端
客服端 一个TEXT要发送的内容 一个CMD按钮 用来发送信息
服务端 也是一样
运行客服端与服务端连接成功时的自动在服务端提示 连接成功
客服务端段开时也提示连接短开
服务端能得知运行客服端电脑的IP
就这么个聊天程序 高手帮忙
Private Sub scksever_ConnectionRequest(ByVal requestID As Long)
If scksever.State <> 0 Then scksever.Close
scksever.Accept requestID
Private Sub Timer1_Timer()
Dim strz As String
Select Case scksever.State
Case 0
strz = "关闭"
Case 1
strz = "打开"
Case 3
strz = "挂起"
Case 6
strz = "正在连接"
Case 7
strz = "已连接"
Text1.Text = scksever.RemoteHostIP
Case 2
strz = "监听"
End Select
StatusBar1.Panels(2).Text = strz
End Sub
End Sub
Case 1 '设主机
scksever.LocalPort = 1007
scksever.RemotePort = 1008
scksever.Listen
MsgBox "设本机为服务器成功!", vbInformation, "提示"
Case 2 '发消息
If scksever.State = 7 Then
sendform.Show 1
Case 3'退出
If scksever.State = 7 Then
scksever.SendData "QUITKHD"
Sleep 50
scksever.Close
End
Private Sub sckclient_Connect()
MsgBox "连接成功", vbInformation, "OK"
connectform.Hide
'进入托盘
With TrayData
.cbSize = Len(TrayData)
.hwnd = Me.hwnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallbackMessage = WM_MOUSEMOVE '触发鼠标移动消息
.hIcon = pic1.Picture '“托盘”中放入窗体图标,你可以把窗体的图标换成你所喜欢的图标
.szTip = "客户端" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, TrayData '调用该函数添加“托盘”
End Sub
一个 客服端 一个服务端
客服端 一个TEXT要发送的内容 一个CMD按钮 用来发送信息
服务端 也是一样
运行客服端与服务端连接成功时的自动在服务端提示 连接成功
客服务端段开时也提示连接短开
服务端能得知运行客服端电脑的IP
就这么个聊天程序 高手帮忙
Private Sub scksever_ConnectionRequest(ByVal requestID As Long)
If scksever.State <> 0 Then scksever.Close
scksever.Accept requestID
Private Sub Timer1_Timer()
Dim strz As String
Select Case scksever.State
Case 0
strz = "关闭"
Case 1
strz = "打开"
Case 3
strz = "挂起"
Case 6
strz = "正在连接"
Case 7
strz = "已连接"
Text1.Text = scksever.RemoteHostIP
Case 2
strz = "监听"
End Select
StatusBar1.Panels(2).Text = strz
End Sub
End Sub
Case 1 '设主机
scksever.LocalPort = 1007
scksever.RemotePort = 1008
scksever.Listen
MsgBox "设本机为服务器成功!", vbInformation, "提示"
Case 2 '发消息
If scksever.State = 7 Then
sendform.Show 1
Case 3'退出
If scksever.State = 7 Then
scksever.SendData "QUITKHD"
Sleep 50
scksever.Close
End
Private Sub sckclient_Connect()
MsgBox "连接成功", vbInformation, "OK"
connectform.Hide
'进入托盘
With TrayData
.cbSize = Len(TrayData)
.hwnd = Me.hwnd
.uID = vbNull
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallbackMessage = WM_MOUSEMOVE '触发鼠标移动消息
.hIcon = pic1.Picture '“托盘”中放入窗体图标,你可以把窗体的图标换成你所喜欢的图标
.szTip = "客户端" & vbNullChar
End With
Shell_NotifyIcon NIM_ADD, TrayData '调用该函数添加“托盘”
End Sub