Private Sub Command1_Click()
Dim s
s = Array(\"春\", \"夏\", \"秋\", \"冬\")
i = Val(InputBox(\"輸入1~4\"))
If i < 1 Or i > 4 Then MsgBox \"輸入錯誤\"
Print (\"季節為\") & s(i - 1)
End
2006-07-15 10:36:29 · 2 個解答 · 發問者 ? 1 in 電腦與網際網路 ➔ 程式設計
怎麼加入無窮迴圈呢??因為老師說他要0以下或4以上的數字輸入以後,不要結束程式只是要跳出視窗,顯示:錯誤是否繼續...哪要怎ㄇ辦呢
2006-07-15 10:42:15 · update #1
Private Sub Command1_Click() Dim s, chk As Boolean, i As Integer chk = True Do While chk s = Array("春", "夏", "秋", "冬") i = Val(InputBox("輸入1~4")) chk = False If i < 1 Or i > 4 Then chk = MsgBox("輸入錯誤,是否繼續", vbYesNo) - vbNo Else Print "季節為" & s(i - 1) End If LoopEnd Sub
2006-07-15 11:04:17 · answer #1 · answered by ? 6 · 0⤊ 0⤋
Private Sub Command1_Click() Dim S, I As Integer S = Array("春", "夏", "秋", "冬") Do I = Int(Val(InputBox("輸入1~4"))) If I < 1 Or I > 4 Then If MsgBox("輸入錯誤,是否繼續輸入?", 4) <> 6 Then Exit Sub Else Exit Do End If Loop Print ("季節為") & S(I - 1)End Sub
2006-07-15 13:17:27 · answer #2 · answered by W.J.S. 7 · 0⤊ 0⤋