?? frmconnection.frm
字號:
VERSION 5.00
Begin VB.Form FrmConnection
BorderStyle = 1 'Fixed Single
Caption = "Connection"
ClientHeight = 2565
ClientLeft = 45
ClientTop = 330
ClientWidth = 4950
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2565
ScaleWidth = 4950
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 2535
Left = 0
TabIndex = 0
Top = 0
Width = 4935
Begin VB.TextBox Text1
Height = 270
Left = 1320
TabIndex = 8
Top = 840
Width = 2175
End
Begin VB.CommandButton CmdExit
Caption = "取消"
Height = 375
Left = 3720
TabIndex = 6
Top = 1920
Width = 975
End
Begin VB.CommandButton CmdOk
Caption = "確定"
Height = 375
Left = 2640
TabIndex = 5
Top = 1920
Width = 975
End
Begin VB.TextBox TxtPost
Height = 270
Left = 1320
TabIndex = 4
Top = 1320
Width = 2175
End
Begin VB.TextBox TxtIP
Height = 270
Left = 1320
TabIndex = 2
Top = 360
Width = 2175
End
Begin VB.Label Label3
Caption = "登陸用戶名:"
Height = 255
Left = 120
TabIndex = 7
Top = 840
Width = 1095
End
Begin VB.Label Label2
Caption = "遠程端口:"
Height = 255
Left = 120
TabIndex = 3
Top = 1320
Width = 1215
End
Begin VB.Label Label1
Caption = "遠程主機IP:"
Height = 255
Left = 120
TabIndex = 1
Top = 360
Width = 1215
End
End
End
Attribute VB_Name = "FrmConnection"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strCharB, strCharA
Dim strSectionTemp As String
Dim strNameTemp As String
Dim strReturn As String
Sub Item_clear()
TxtIP = ""
TxtPost = ""
End Sub
Function setProfile(strFileName As String, strSection As String, strname As String, strSave As String) As Boolean
'這個函數是用來對INI文件進行寫操作的
'函數說明:
'strFileName 是所要存儲的文件名
'strSection 是這個文件中的一個節點名
'strName 是所要查找的字段名
'strSave 是所要替換字段值
'薛向華 1998/05/13
Dim strtemp As String
Dim strfileback As String
Dim strReturn As String
strfileback = App.Path & "\系統文件\System.tmp" '臨時文件是用來存放中轉信息的
Open strFileName For Input As #1
Open strfileback For Output As #2
Do While Not EOF(1)
Line Input #1, strtemp
strReturn = strtemp
Print #2, strReturn
If InStr(1, Trim(strtemp), "[") <> 0 Then
If InStr(1, Trim(strtemp), Trim(strSection)) <> 0 Then
Do While Not EOF(1)
Line Input #1, strtemp
If InStr(1, Trim(strtemp), Trim(strname)) <> 0 Then Exit Do '找到所要修改的字段值
strReturn = strtemp
Print #2, strReturn '拷貝不需要的字段值
Loop
strReturn = strname & "=" & strSave '修改
Print #2, strReturn
End If
End If
Loop
Close #1
Close #2
Open strfileback For Input As #1
Open strFileName For Output As #2
Do While Not EOF(1) And EOF(2)
Line Input #1, strReturn
Print #2, strReturn
Loop
Close #1
Close #2
End Function
Function GetProfile(strFileName As String, strSection As String, strname As String) As String
'這個函數是用來對INI文件進行讀操作的
'函數說明:
'strFileName 是所要讀取的文件名
'strSection 是這個文件中的一個節點名
'strName 是所要查找的字段名
'返回值:
'薛向華 1998/05/13
strSectionTemp = ""
strNameTemp = ""
strReturn = ""
On Error GoTo ErrSrchSection
Open strFileName For Input As #1
' 下面這段程序是用來查找節點的
Do While Not EOF(1)
strCharA = Input(1, #1)
If strCharA = "[" Then
Do While Not EOF(1)
strCharB = Input(1, #1)
If strCharB = "]" Then Exit Do
strSectionTemp = strSectionTemp & strCharB
Loop
End If
If strSectionTemp = strSection Then
strCharA = Input(2, #1)
Exit Do
Else
strSectionTemp = ""
End If
Loop
On Error GoTo ErrReadFile
AA:
'下面這段程序是用來查找所要查找的字段的
strNameTemp = ""
Do While Not EOF(1)
strCharA = Input(1, #1)
If strCharA <> "=" Then
strNameTemp = strNameTemp & strCharA '得到名稱
Else
Exit Do
End If
Loop
If strNameTemp = strname Then
Line Input #1, strReturn '如果找到與它匹配的字段名,就返回得到的值
Else
Line Input #1, strReturn '如果未找到與它匹配的字段名,就繼續找
GoTo AA
End If
Close #1
GetProfile = strReturn
Exit Function
ErrReadFile:
Exit Function
ErrSrchSection:
MsgBox "節點未找到", vbOKOnly
GetProfile = ""
Close #1
End Function
Private Sub CmdExit_Click()
Unload Me
frmClient.Enabled = True
End Sub
Private Sub CmdOk_Click()
On Error Resume Next
Dim strPath As String
If TxtIP.text = Empty Or TxtPost.text = Empty Or Text1.text = Empty Then
MsgBox "地址內容不能是空值!", vbExclamation + vbOKOnly, "系統提示"
Exit Sub
Else
If Text1.MaxLength > 4 Then
Text1.text = Left(Text1.text, 4)
End If
If Text1.MaxLength = 1 Then
Text1.text = Text1.text & "@@@"
ElseIf Text1.MaxLength = 2 Then
Text1.text = Text1.text & "@@"
ElseIf Text1.MaxLength = 3 Then
Text1.text = Text1.text & "@"
End If
strPath = App.Path & "\系統文件\System.ini"
setProfile strPath, "[database]", "remName", Text1.text
setProfile strPath, "[database]", "remIP", TxtIP
setProfile strPath, "[database]", "RemPort", TxtPost
Me.Hide
FrmPass.Show
End If
End Sub
Private Sub Form_Load()
On Error Resume Next
Dim strPath As String
If Dir(App.Path & "\系統文件\System.ini") = Empty Then
Open App.Path & "\系統文件\System.ini" For Output As #1
Print #1, "[database]" & vbCrLf & "remName=" & vbCrLf & "remIP=" & "remPORT=" & vbCrLf & "dbparm=" & vbCrLf & "RemPort=" & vbCrLf
Close #1
End If
On Error Resume Next
barHigh.Width = 0
Dim strPatht As String
strPatht = App.Path & "\系統文件\System.ini"
If strPatht <> "" Then
TxtIP.text = GetProfile(strPatht, "database", "remIP")
TxtPost.text = GetProfile(strPatht, "database", "RemPort")
Text1.text = GetProfile(strPatht, "database", "remName")
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -