VBA中inputbox返回值

2025-05-22 16:39:59
推荐回答(3个)
回答1:

Private Sub iCheckGs()
'--------验证密码
Dim iPsw$, i&, tmp
iPsw = " " '"300029"
Do
tmp = InputBox( _
"系统温馨提醒:" & Chr(10) & Chr(10) & _
"非专业用户请点击{取消}退出!" & Chr(10) & Chr(10) & _
"请输入密码(您还有 " & 3 - i & " 次机会!)")
If Len(tmp) = 0 Then Exit Sub
If CStr(tmp) = iPsw Then Exit Do
If i >= 2 Then
Application.DisplayAlerts = False
ThisWorkbook.Close False
Application.DisplayAlerts = True
End If
i = i + 1
Loop
'下面是密码通过后的代码
……
……

回答2:

可以用 Input,比如下面这段:

Sub tst()
Dim aa$
aa = InputBox("输入一个范围")
Range(aa).Select
End Sub

用文本框也一样,如
range(text1.text).select

回答3:

你的代码怎么写?