?? frmclient.frm
字號:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmClient
BorderStyle = 1 'Fixed Single
Caption = "聊天程序_客戶端"
ClientHeight = 4596
ClientLeft = 48
ClientTop = 336
ClientWidth = 5136
Icon = "frmclient.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4596
ScaleWidth = 5136
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdQuit
Caption = "斷開"
Height = 375
Left = 3840
TabIndex = 9
Top = 3600
Width = 1230
End
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 375
Left = 3825
TabIndex = 8
Top = 4080
Width = 1230
End
Begin RichTextLib.RichTextBox rtbIn
Height = 2292
Left = 72
TabIndex = 7
Top = 960
Width = 4980
_ExtentX = 8784
_ExtentY = 4043
_Version = 393217
BackColor = 16777215
Enabled = -1 'True
ReadOnly = -1 'True
ScrollBars = 2
TextRTF = $"frmclient.frx":0442
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComctlLib.ImageList ImageList1
Left = 5520
Top = 3960
_ExtentX = 995
_ExtentY = 995
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 4
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmclient.frx":04E1
Key = "login"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmclient.frx":07FD
Key = "connect"
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmclient.frx":0B19
Key = "save"
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmclient.frx":0C2D
Key = "quit"
EndProperty
EndProperty
End
Begin VB.CommandButton cmdConnect
Caption = "連接"
Height = 375
Left = 3840
TabIndex = 4
Top = 120
Width = 1230
End
Begin VB.TextBox txtPort
BackColor = &H00FFFFFF&
Height = 450
Left = 960
TabIndex = 3
Top = 528
Width = 2655
End
Begin VB.TextBox txtHost
BackColor = &H00FFFFFF&
Height = 390
Left = 960
TabIndex = 2
Top = 120
Width = 2670
End
Begin VB.TextBox txtOut
Height = 855
Left = 90
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 3600
Width = 3675
End
Begin MSWinsockLib.Winsock tcpClient
Left = 3240
Top = 3240
_ExtentX = 593
_ExtentY = 593
_Version = 393216
End
Begin VB.Label Label3
BackColor = &H00FF0000&
BackStyle = 0 'Transparent
Caption = "端口號"
ForeColor = &H00000000&
Height = 372
Left = 168
TabIndex = 6
Top = 600
Width = 816
End
Begin VB.Label Label2
BackColor = &H00FF0000&
BackStyle = 0 'Transparent
Caption = "輸入框"
ForeColor = &H00000000&
Height = 252
Left = 108
TabIndex = 5
Top = 3360
Width = 1068
End
Begin VB.Label lblName
BackColor = &H00FF0000&
BackStyle = 0 'Transparent
Caption = "服務(wù)器IP"
ForeColor = &H00000000&
Height = 240
Left = 120
TabIndex = 1
Top = 180
Width = 840
End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim NewClient As Boolean
Private Sub cmdConnect_Click()
On Error GoTo errhandle:
tcpClient.RemoteHost = txtHost.Text
tcpClient.RemotePort = txtPort.Text
tcpClient.Connect
txtHost.Locked = True
txtPort.Locked = True
NewClient = True
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
Private Sub cmdExit_Click()
Unload frmClient
End Sub
Private Sub cmdQuit_Click()
On Error GoTo errhandle:
tcpClient.SendData "Q" & CStr(Now())
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
Me.cmdQuit.Enabled = False
End Sub
Private Sub tcpClient_Connect()
tcpClient.SendData "C"
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
tcpClient.GetData sData
If sData = "C_OK" Then
cmdQuit.Enabled = True
MsgBox "連接成功!"
NewClient = False
End If
rtbIn.Text = rtbIn.Text + Chr(10) + sData + CStr(Now())
rtbIn.SelStart = Len(sData)
If sData = "Q_OK" Then
tcpClient.Close
End If
End Sub
Private Sub txtOut_KeyUp(KeyCode As Integer, Shift As Integer)
On Error GoTo errhandle:
If KeyCode = 13 Then
tcpClient.SendData "客戶端:" & txtOut.Text
rtbIn.Text = rtbIn.Text + Chr(10) + "客戶端:" & txtOut.Text & CStr(Now())
txtOut.Text = ""
End If
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -