VB编程inputbox中为空如何表示 当前窗体被关闭的语句如何写

来源:百度知道 编辑:UC知道 时间:2024/05/19 15:47:53
dim a,ctr
ctr=0 '计数器
const pass="123456"'密码

do

if ctr=3 then
a=inputbox("password")
msgbox("shit")

exit do

else

a=inputbox("password")
if a=pass then
msgbox("yes")

exit do

else

ctr=ctr+1'增加错误次数

msgbox("wrong")

end if
end if
loop
每次关闭窗体 和 输入为空的时候也显示错误
怎么能让关闭窗体的时候程序就停止
输入为空的时候不显示错误而是 直接容许再一次输入

else
ctr=ctr+1'增加错误次数
msgbox("wrong")
end if

else下加 if a="" then exit do

inputbox内容为空的时候返回""空字符串.要用if a is "" then......判断.
一下这段载自MSDN
Dim message, title, defaultValue As String
Dim myValue As Object
' Set prompt.
message = "Enter a value between 1 and 3"
' Set title.
title = "InputBox Demo"
defaultValue = "1" ' Set default value.

' Display message, title, and default value.
myValue = InputBox(message, title, defaultValue)
' If user has clicked Cancel, set myValue to defaultValue
If myValue Is "" Then myValue = defaultValue

' Display dialog box at position 100, 100.
myValue = InputBox(message, title, defaultValue, 100, 100)
' If user has clicked Cancel, set myValue to defaultValue
If myValue Is "" Then myValue = defaultValue