0
當我運行以下代碼片段並輸入可接受的值時,我會得到所需的結果。在輸入框中驗證用戶輸入
do while len(strselect) = 0 'or strselect<>"1" or strselect<>"2" or strselect<>"3"
strselect = inputbox ("Please select:" &vbcrlf&vbcrlf&_
"1. Add an entry" &vbcrlf&vbcrlf&_
"2. Remove an entry" &vbcrlf&vbcrlf&_
"3. Search for an entry" &vbcrlf, "Contact Book")
if isempty(strselect) then
wscript.quit()
elseif strselect="1" then
wscript.echo "You chose 1"
elseif strselect="2" then
wscript.echo "You chose 2"
elseif strselect="3" then
wscript.echo "You chose 3"
end if
loop
但是,如果我試圖進一步限制驗證過程(通過在do while
條件的話),然後再次運行該代碼段,我得到相應的if
觸發條件,但do
循環繼續,而不是退出, 。
我使用isnumeric
和cstr
在do
循環strselect
條件,沒有快樂試過......我缺少的是拿到混賬東西退出循環?
非常感謝MC ND,插圖精美的答案。我的錯誤現在很清楚,因爲昨晚它令人沮喪地無法確定。我會修改我的邏輯運算符和我的邏輯!後急...再次感謝! :) –