【VB开源代码栏目提醒】:网学会员,鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“FrmCnn.frm”一文,供大家参考学习!
VERSION 5.00
Begin VB.Form FrmCnn
BackColor = &H00D9722D&
BorderStyle = 1 'Fixed Single
Caption = "连接服务器"
ClientHeight = 2070
ClientLeft = 5700
ClientTop = 4260
ClientWidth = 4080
LinkTopic = "Form2"
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 2070
ScaleWidth = 4080
Begin VB.TextBox TextSvrIP
Height = 375
Left = 1680
TabIndex = 6
Text = "127.0.0.1"
Top = 1080
Width = 2295
End
Begin VB.CommandButton CmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 2640
TabIndex = 5
Top = 1560
Width = 1095
End
Begin VB.CommandButton CmdCnn
Caption = "连接"
Default = -1 'True
Height = 375
Left = 1320
TabIndex = 4
Top = 1560
Width = 1095
End
Begin VB.TextBox TextPwd
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
Pass
wordChar = "*"
TabIndex = 3
Top = 600
Width = 2295
End
Begin VB.TextBox TextUser
Height = 375
Left = 1680
TabIndex = 2
Top = 120
Width = 2295
End
Begin
VB.Label LabelIP
BackStyle = 0 'Transparent
Caption = "服务器IP:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 255
Left = 120
TabIndex = 7
Top = 1080
Width = 1695
End
Begin VB.Label LabelPwd
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "密码:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 375
Left = 720
TabIndex = 1
Top = 600
Width = 975
End
Begin VB.Label LabelUser
BackStyle = 0 'Transparent
Caption = "管理员ID:"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 2055
End
End
Attribute VB_Name = "FrmCnn"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CmdCancel_Click() '取消
Unload Me
End Sub
'连接服务器
Private Sub CmdCnn_Click()
'检验输入内容并存入内存
If Len(Trim(Me.TextUser.Text)) <= 0 Then '用户名
MsgBox "请输入用户ID!"
Exit Sub
ElseIf Len(Trim(Me.TextUser.Text)) > 16 Then
MsgBox "您输入的用户ID过长!"
Exit Sub
Else '输入正确
UserNow.ID = Trim(Me.TextUser.Text)
End If
If Len(Trim(Me.TextPwd.Text)) <= 0 Then '密码
MsgBox "请输入密码!"
Exit Sub
ElseIf Len(Trim(Me.TextPwd.Text)) > 16 Then
MsgBox "您输入的密码过长!"
Exit Sub
Else '输入正确
UserNow.Pwd = Trim(Me.TextPwd.Text)
End If
If Len(Trim(Me.TextSvrIP.Text)) <= 0 Then 'IP
MsgBox "请输入服务器IP!"
Exit Sub
ElseIf Len(Trim(Me.TextSvrIP.Text)) > 15 Then
MsgBox "您输入的IP地址过长!"
Exit Sub
ElseIf Len(Trim(Me.TextSvrIP.Text)) < 7 Then
MsgBox "您输入的IP地址过短!"
Exit Sub
Else '输入正确
'设置服务器IP,端口
MDIFrm.SockToSvr.RemoteHost = Trim(Me.TextSvrIP.Text)
MDIFrm.SockToSvr.RemotePort = 1234
'连接服务器
MDIFrm.SockToSvr.Connect
'在状态栏显示服务器连接状态
MDIFrm.StatusBar1.Panels(1).Text = "服务器连接状态:正在连接…"
'退出本窗口
Unload Me
End If
End Sub
Private Sub Form_Load()
'检验sock状态,如果正在连接则关闭原连接,以便建立新连接
If MDIFrm.SockToSvr.State <> sckClosed Then
MDIFrm.SockToSvr.Close
End If
End Sub