📄 connect.frm
字号:
VERSION 5.00
Begin VB.Form Connect
BorderStyle = 1 'Fixed Single
Caption = "连接"
ClientHeight = 4290
ClientLeft = 45
ClientTop = 330
ClientWidth = 4455
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Connect.frx":0000
LinkTopic = "Form2"
MaxButton = 0 'False
ScaleHeight = 4290
ScaleWidth = 4455
StartUpPosition = 2 '屏幕中心
Begin VB.CheckBox Check2
Caption = "记住密码"
Height = 255
Left = 120
TabIndex = 11
Top = 3960
Width = 1815
End
Begin VB.CheckBox Check1
Caption = "新用户"
Height = 255
Left = 120
TabIndex = 10
Top = 3720
Value = 1 'Checked
Width = 1215
End
Begin VB.TextBox Text3
Height = 285
Left = 1800
TabIndex = 8
Text = "127.0.0.1"
Top = 3000
Width = 1815
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1
Left = 120
Top = 3720
End
Begin VB.CommandButton Command2
Caption = "关闭(&C)"
Height = 375
Left = 2040
TabIndex = 7
Top = 3760
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确定(&O)"
Default = -1 'True
Height = 375
Left = 3120
TabIndex = 6
Top = 3760
Width = 1095
End
Begin VB.TextBox Text2
Height = 285
HideSelection = 0 'False
IMEMode = 3 'DISABLE
Left = 1800
TabIndex = 5
Top = 2520
Width = 1815
End
Begin VB.TextBox Text1
Height = 285
Left = 1800
TabIndex = 3
Top = 2160
Width = 1815
End
Begin VB.Image Image1
Height = 480
Left = 240
Picture = "Connect.frx":000C
Top = 360
Width = 480
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "服务器:"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 480
TabIndex = 9
Top = 3045
Width = 630
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密 码:"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 480
TabIndex = 4
Top = 2565
Width = 615
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名:"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 195
Left = 480
TabIndex = 2
Top = 2205
Width = 630
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "欢迎使用本软件,如果您是第一次使用,请选择“注册”,如果您是注册用户,请输入您的用户名,密码。"
ForeColor = &H00FFFFFF&
Height = 1155
Left = 840
TabIndex = 1
Top = 600
Width = 3105
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "欢迎"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 195
Left = 840
TabIndex = 0
Top = 360
Width = 390
End
Begin VB.Shape Shape1
BackColor = &H00800000&
BackStyle = 1 'Opaque
Height = 1815
Left = 120
Top = 120
Width = 4215
End
Begin VB.Shape Shape2
BackColor = &H00E0E0E0&
BackStyle = 1 'Opaque
Height = 1695
Left = 120
Top = 1920
Width = 4215
End
End
Attribute VB_Name = "Connect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'==================
'连接服务器模块
'==================
'================
'将信息提交服务器
'================
Private Sub Command1_Click()
'开始检查输入合法性
'用户名和密码不能包含回车
If InStr(1, Text1.Text, Chr(32)) Or InStr(1, Text2.Text, Chr(32)) Then
MsgBox "No spaces allowed in your ID or password"
Exit Sub
End If
'用户名不能为空
If Text1.Text = "" Then
MsgBox "You forgot to enter your ID!"
Exit Sub
End If
'密码不能为空
If Text2.Text = "" Then
MsgBox "You forgot to enter your password!"
Exit Sub
End If
'服务器IP不能为空
If Text3.Text = "" Then
MsgBox "You forgot to enter a server address!"
Exit Sub
End If
'是否保存密码
If Check2.value = 1 Then
KeySection = "General"
KeyKey = "SaveInfoCheck"
KeyValue = "True"
'保存信息到INI文件
SaveINI
KeyKey = "ID"
KeyValue = Text1.Text
'保存用户名到INI文件
SaveINI
KeyKey = "Password"
KeyValue = Text2.Text
'保存密码到INI文件
SaveINI
KeyKey = "ServerIP"
KeyValue = Text3.Text
'保存服务器IP到INI文件
SaveINI
Else
KeySection = "General"
KeyKey = "SaveInfoCheck"
KeyValue = "False"
SaveINI
KeySection = "General"
KeyKey = "ID"
KeyValue = Text1.Text
SaveINI
KeySection = "General"
KeyKey = "Password"
KeyValue = ""
SaveINI
KeySection = "General"
KeyKey = "ServerIP"
KeyValue = Text3.Text
SaveINI
End If
'新注册用户
If Check1.value = 1 Then
KeySection = "General"
KeyKey = "Newbie"
KeyValue = "Yes"
'保存到INI文件,新注册
SaveINI
MyPersonalInfo.Sex = "N/A"
MyPersonalInfo.Country = "N/A"
MyPersonalInfo.BirthDay = "N/A"
MyPersonalInfo.Age = "N/A"
MyPersonalInfo.Webpage = "N/A"
MyPersonalInfo.About = "N/A"
'将新用户保存到文件info.dat
Open "Info.dat" For Random As gFileNum Len = Len(MyPersonalInfo)
Put #gFileNum, 1, MyPersonalInfo
Close #gFileNum
Else
KeySection = "General"
KeyKey = "Newbie"
KeyValue = "No"
SaveINI
End If
'注册过程,将“确定”键,用户名,密码文本框屏蔽
Command1.Enabled = False
Command2.Caption = "&Cancel"
Text1.Enabled = False
Text2.Enabled = False
Label3.ForeColor = &H808080
Label4.ForeColor = &H808080
Label1.Caption = "Connecting..."
Label2.Caption = "Great! Now all you have to do is sit back and relax, I'll connect to the server."
'连接服务器
MyIM.Winsock1.RemoteHost = Text3.Text
MyIM.Winsock1.Connect
Timer1.Enabled = True
'MyIM.Show
End Sub
Private Sub Command2_Click()
'如果command2为取消状态的话,取消连接服务器,否则关闭窗体
If Command2.Caption = "&Cancel" Then
Label1.Caption = "Connection Canceled."
Label2.Caption = "Ok, I've stopped trying to connect. When your ready to try again, hit the Proceed button."
Label3.ForeColor = vbBlack
Label4.ForeColor = vbBlack
Text1.Enabled = True
Text2.Enabled = True
Command1.Enabled = True
Command2.Caption = "&Close"
MyIM.Winsock1.Close
Command2.Caption = "&Close"
Else
'关闭窗体,关闭窗体MYIM
Unload Me
Unload MyIM
End
End If
End Sub
'===============
'窗体初使化
'===============
Private Sub Form_Load()
'读INI文件,将用户名,密码,服务器地址显示到文本框中
KeySection = "General"
KeyKey = "ID"
LoadINI
'Text1.Text = KeyValue
KeySection = "General"
KeyKey = "Password"
LoadINI
'Text2.Text = KeyValue
KeySection = "General"
KeyKey = "ServerIP"
LoadINI
'Text3.Text = KeyValue
KeySection = "General"
KeyKey = "SaveInfoCheck"
LoadINI
Dim Temp2 As String
Temp2 = KeyValue
If InStr(1, Temp2, "True") Then
Check2.value = 1
Else
Check2.value = 0
End If
KeySection = "General"
KeyKey = "Newbie"
LoadINI
Temp2 = KeyValue
If InStr(1, Temp2, "No") Then
Check1.value = 0
Else
Check1.value = 1
End If
gFileNum = FreeFile
End Sub
Private Sub Timer1_Timer()
'If MyIM.Winsock1.State = sckConnected Then
' Label1.Caption = "Verifying ID and Password..."
' Dim Temp2 As String
' If Check1.value = 1 Then
' Temp2 = "Yes"
' Else
' Temp2 = "No"
' End If
' MyIM.Winsock1.SendData ".login " & Text1 & " " & Text2 & " " & Temp2
Timer1.Enabled = False
'End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -