Option Explicit
Dim b As Single
Private Sub Command1_Click()
Dim a, s, n%
Open "c:\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, s
a = Split(Trim(s), " ")
If Text1.Text = a(0) And Text2.Text = a(2) Then
Loop
Form1.Hide
Load Form2
Form2.Show
Else
MsgBox "密碼錯誤!請重新輸入!"
Text2.Text = ""
If b = 2 Then
MsgBox "對不起密碼輸錯三次后銀行自動吞卡!"
Command1.Enabled = False
Command2.Enabled = False
End If
End If
b = b + 1
End Sub
我已經不知道怎么改了 LOOP也不知道加哪里 現在是用戶密碼對了也進不去
uj5u.com熱心網友回復:
a = Split(Trim(s), " ")Trim(s) 已經將s字串中的空格全部清除了,還能檢測出空格嗎?
uj5u.com熱心網友回復:
Option Explicit
Dim b As Single
Private Sub Command1_Click()
Dim a() As String, s As String, success As Boolean
Open "c:\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, s
a = Split(Trim(s), " ")
If Text1.Text = a(0) And Text2.Text = a(2) Then
success = True
Exit Do
End If
Loop
Close #1
If success Then
b = 0
Form1.Hide
Load Form2
Form2.Show
Else
b = b + 1
If b = 3 Then
MsgBox "對不起密碼輸錯三次后銀行自動吞卡!"
Command1.Enabled = False
Command2.Enabled = False
Else
MsgBox "密碼錯誤!請重新輸入!"
Text2.Text = ""
End If
End If
End Sub
uj5u.com熱心網友回復:
Trim 只能“掐頭去尾”。uj5u.com熱心網友回復:
能吐錢就好了。
uj5u.com熱心網友回復:
Dim b As Single
Private Sub Command1_Click()
Dim a, s, S1, n%
Open App.Path & "\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, S1 '如果文本檔案有多行,必須這樣處理。如果只有一行,不需要DO回圈。
s = s & Space(1) & S1 '將各行內容存盤在 s 變數中
Loop
Close #1
a = Split(Trim(s), " ") '在這里存盤陣列
If Text1.Text = a(0) And Text2.Text = a(2) Then '名稱密碼正確
Unload Form1 '關閉Form1 界面,并且從記憶體中清除
Form2.Show '打開Form2 界面
Else
MsgBox "密碼錯誤!請重新輸入!"
Text2.Text = ""
If b = 2 Then
MsgBox "對不起密碼輸錯三次后銀行自動吞卡!"
Command1.Enabled = False
Command2.Enabled = False
End If
End If
b = b + 1
End Sub
我除錯了一下,這樣就沒有問題了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/72116.html
標籤:VB基礎類
上一篇:請問,win8系統,我做個程式想安裝在 Program Files (x86) 目錄里,該檔案夾允許拷貝檔案,但不能注冊Dll檔案,請問是怎么回事?該怎么辦?謝
下一篇:VBA簡單建模
