?? frmaddress.frm
字號:
VERSION 5.00
Begin VB.Form frmAddress
BorderStyle = 3 'Fixed Dialog
Caption = "地址簿"
ClientHeight = 3708
ClientLeft = 2952
ClientTop = 2628
ClientWidth = 5280
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3708
ScaleWidth = 5280
ShowInTaskbar = 0 'False
Begin VB.Frame Frame1
Caption = "站點(diǎn)描述"
Height = 1560
Left = 36
TabIndex = 5
Top = 2088
Width = 5160
Begin VB.TextBox txtSite
Height = 360
Left = 3708
TabIndex = 13
Top = 792
Width = 1272
End
Begin VB.TextBox txtAuto
Height = 336
Left = 900
TabIndex = 11
Text = "\n"
Top = 792
Width = 2028
End
Begin VB.TextBox txtPort
Height = 324
Left = 3600
TabIndex = 9
Text = "23"
Top = 252
Width = 1416
End
Begin VB.TextBox txtAdd
Height = 300
Left = 612
TabIndex = 7
Top = 252
Width = 2136
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "\n表示回車"
Height = 192
Left = 108
TabIndex = 14
Top = 1224
Width = 732
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "站點(diǎn)名"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 3024
TabIndex = 12
Top = 828
Width = 576
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "自動登錄"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 72
TabIndex = 10
Top = 828
Width = 768
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "端口"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 3132
TabIndex = 8
Top = 288
Width = 384
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "地址"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.6
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 108
TabIndex = 6
Top = 288
Width = 384
End
End
Begin VB.CommandButton cmdExit
Caption = "取消"
Height = 372
Left = 3780
TabIndex = 4
Top = 1692
Width = 1452
End
Begin VB.CommandButton cmdAdd
Caption = "加入站點(diǎn)"
Height = 372
Left = 3780
TabIndex = 3
Top = 636
Width = 1452
End
Begin VB.CommandButton cmdDel
Caption = "刪除站點(diǎn)"
Height = 372
Left = 3816
TabIndex = 2
Top = 1164
Width = 1452
End
Begin VB.CommandButton cmdConnect
Caption = "連接站點(diǎn)"
Height = 372
Left = 3780
TabIndex = 1
Top = 108
Width = 1452
End
Begin VB.ListBox ListAdd
Columns = 2
Height = 1968
ItemData = "frmAddress.frx":0000
Left = 36
List = "frmAddress.frx":0002
TabIndex = 0
Top = 108
Width = 3612
End
End
Attribute VB_Name = "frmAddress"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim SiteInfo(100, 3) As String
Dim SiteNum As Integer
Dim IP As String, Port As Integer, mvarAction As Command
Dim LoginString As String
Public Enum Command
comdOK
comdCancel
End Enum
Public Property Let Action(ByVal vData As Command)
mvarAction = vData
End Property
Public Property Get Action() As Command
Action = mvarAction
End Property
Public Property Get IPAddress() As String
IPAddress = IP
End Property
Public Property Get PortNum() As Integer
PortNum = Port
End Property
Public Property Let IPAddress(ByVal tempIP As String)
IP = tempIP
End Property
Public Property Let PortNum(ByVal tempPort As Integer)
Port = tempPort
End Property
Public Property Get LoginStr()
LoginStr = LoginString
End Property
Private Sub cmdAdd_Click()
Dim FileNum As Integer
Dim I As Integer
Dim Founded, Changed As Boolean
If CheckTxt Then
'查找新增加的站點(diǎn)以前是否加入過
For I = 0 To SiteNum - 1
If SiteInfo(I, 0) = Trim(txtSite.Text) Then
Founded = True
If SiteInfo(I, 1) <> Trim(txtAdd.Text) Or SiteInfo(I, 3) <> txtAuto.Text Or SiteInfo(I, 2) <> Trim(txtPort.Text) Then
Changed = True
SiteInfo(I, 1) = Trim(txtAdd.Text)
SiteInfo(I, 2) = Trim(txtPort.Text)
SiteInfo(I, 3) = txtAuto.Text
ListAdd.ListIndex = I
End If
Exit For
End If
Next I
If Not Founded Then
ListAdd.AddItem Trim(txtSite.Text)
SiteInfo(SiteNum, 0) = txtSite.Text
SiteInfo(SiteNum, 1) = txtAdd.Text
SiteInfo(SiteNum, 2) = txtPort.Text
SiteInfo(SiteNum, 3) = txtAuto.Text
ListAdd.ListIndex = SiteNum
SiteNum = SiteNum + 1
'獲得一個沒有被占用的文件號
FileNum = FreeFile
'以增加的模式打開文件
Open App.Path & "\address.txt" For Append As FileNum
'寫入一個站點(diǎn)的信息
Print #FileNum, Trim(txtSite.Text) & "--" & Trim(txtAdd.Text) & "--" & Trim(txtPort.Text) & "--" & txtAuto.Text
'關(guān)閉文件
Close #FileNum
ElseIf Founded And Changed Then
'獲得一個沒有被占用的文件號
FileNum = FreeFile
'以output的模式打開文件
Open App.Path & "\address.txt" For Output As FileNum
For I = 0 To ListAdd.ListCount - 1
'循環(huán)寫入每個站點(diǎn)的信息
Print #FileNum, SiteInfo(I, 0) & "--" & SiteInfo(I, 1) & "--" & SiteInfo(I, 2) & "--" & SiteInfo(I, 3)
Next I
'關(guān)閉文件
Close #FileNum
End If
End If
End Sub
Private Sub cmdConnect_Click()
IP = Trim(txtAdd.Text)
Port = CInt(txtPort.Text)
LoginString = Trim(txtAuto.Text)
mvarAction = comdOK
Unload Me
End Sub
Private Sub cmdDel_Click()
Call DelSite
'將站點(diǎn)數(shù)減少一
SiteNum = SiteNum - 1
'刪除列表框中的項(xiàng)
ListAdd.RemoveItem (ListAdd.ListIndex)
'刪除后回到的一項(xiàng)
If ListAdd.ListCount > 0 Then
ListAdd.ListIndex = 0
SetTxt (0)
Else
ClearTxt
End If
End Sub
Private Sub cmdExit_Click()
mvarAction = comdCancel
Unload Me
End Sub
Private Sub Form_Load()
Dim FileNum As Integer
Dim Address, tempPort, SiteDesc, AutoLogin, TempStr As String
SiteNum = 0
'獲得一個文件號
FileNum = FreeFile
'打開一個文本文件
If Dir(App.Path & "\address.txt") <> "" Then
Open App.Path & "\address.txt" For Input As FileNum
'循環(huán)讀取地址該文件中的所有數(shù)據(jù)
Do While Not EOF(FileNum)
Line Input #FileNum, TempStr
GetValue (TempStr)
Loop
Close #FileNum
End If
End Sub
Private Sub ListAdd_Click()
SetTxt (ListAdd.ListIndex)
End Sub
Private Sub ClearTxt()
txtSite.Text = ""
txtAdd.Text = ""
txtAuto.Text = ""
txtPort.Text = ""
End Sub
Private Sub SetTxt(Index As Integer)
txtSite.Text = SiteInfo(Index, 0)
txtAdd.Text = SiteInfo(Index, 1)
txtPort.Text = SiteInfo(Index, 2)
txtAuto.Text = SiteInfo(Index, 3)
End Sub
Private Sub DelSite()
Dim I, FileNum As Integer
FileNum = FreeFile
Open App.Path & "\address.txt" For Output As FileNum
For I = 0 To SiteNum - 1
If I <> ListAdd.ListIndex Then
Print #FileNum, SiteInfo(I, 0) & "--" & SiteInfo(I, 1) & "--" & SiteInfo(I, 2) & "--" & SiteInfo(I, 3)
End If
If I > ListAdd.ListIndex Then
ChangeValue (ListAdd.ListIndex)
End If
Next I
Close #FileNum
End Sub
Private Sub ChangeValue(I As Integer)
SiteInfo(I, 0) = SiteInfo(I + 1, 0)
SiteInfo(I, 1) = SiteInfo(I + 1, 1)
SiteInfo(I, 2) = SiteInfo(I + 1, 2)
SiteInfo(I, 3) = SiteInfo(I + 1, 3)
End Sub
Private Sub GetValue(TempStr As String)
Dim info As Variant
If Trim(TempStr) <> "" Then
info = Split(TempStr, "--", , vbTextCompare)
SiteInfo(SiteNum, 0) = info(0)
SiteInfo(SiteNum, 1) = info(1)
SiteInfo(SiteNum, 2) = info(2)
SiteInfo(SiteNum, 3) = info(3)
ListAdd.AddItem info(0)
SiteNum = SiteNum + 1
End If
End Sub
Private Function CheckTxt() As Boolean
If Trim(txtAdd.Text) = "" Then
MsgBox "請輸入服務(wù)器地址!"
txtAdd.SetFocus
CheckTxt = False
Exit Function
End If
If Trim(txtPort.Text) = "" Then
MsgBox "請輸入端口號,默認(rèn)為23!"
txtPort.SetFocus
CheckTxt = False
Exit Function
End If
If Trim(txtSite.Text) = "" Then
MsgBox "請輸入站點(diǎn)描述!"
txtSite.SetFocus
CheckTxt = False
Exit Function
End If
If Trim(txtAuto.Text) = "" Then
txtAuto.Text = " "
End If
CheckTxt = True
End Function
Private Sub ListAdd_DblClick()
Call cmdConnect_Click
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -