錯誤也許我沒有看到,但我真的相信,我有一個做永遠循環!有人可以幫忙嗎?我從頭開始做,這樣我就可以讓用戶再次使用代碼。感謝任何幫助人。我有說我有一個循環沒有做
代碼:
'Written by Douglas Howe
Option Explicit
Dim colorPicOne, colorPicTwo, tryAgain
'initial do
do
'first prompt
do
Wscript.StdOut.WriteLine "Pick a primary color (i.e blue, red, or yellow): "
colorPicOne = lcase(wscript.StdIn.ReadLine)
if colorPicOne <> "blue" and colorPicOne <> "red" and colorPicOne <> "yellow" then
Wscript.StdOut.WriteLine "Not a primary color! Please pick another color: "
else
exit do
end if
loop while colorPicOne <> "blue" OR colorPicOne <> "red" or colorPicOne <> "yellow"
'second prompt
do
Wscript.StdOut.WriteLine "Pick another primary color (i.e blue, red, or yellow): "
colorPicTwo = lcase(wscript.StdIn.ReadLine)
if colorPicTwo <> "blue" and colorPicTwo <> "red" and colorPicTwo <> "yellow" then
Wscript.StdOut.WriteLine "Not a primary color! Please pick another color: "
else
exit do
end if
loop while colorPicTwo <> "blue" OR colorPicTwo <> "red" or colorPicTwo <> "yellow"
if colorPicOne = "red" and colorPicTwo = "blue" then
Wscript.StdOut.Writeline "Your color is purple!"
else
if colorPicOne = "blue" and colorPicTwo ="red" then
Wscript.StdOut.Writeline "Your color is purple!"
end if
if colorPicOne = "red" and colorPicTwo = "yellow" then
Wscript.StdOut.Writeline "Your color is orange!"
else
if colorPicOne = "yellow" and colorPicTwo ="red" then
Wscript.StdOut.Writeline "Your color is orange!"
end if
if colorPicOne = "blue" and colorPicTwo = "yellow" then
Wscript.StdOut.Writeline "Your color is green!"
else
if colorPicOne = "yellow" and colorPicTwo ="blue" then
Wscript.StdOut.Writeline "Your color is green!"
end if
Wscript.Stdout.WriteLine "Would you like to try again? (yes or no) :"
tryAgain =lcase(Wscript.StdIn.ReadLine)
if tryAgain = "no" then
Wscript.Stdout.WriteLine "Have a nice day"
exit do
if tryAgain = "yes" then
Wscript.Stdout.WriteLine "Ok!"
else
Wscript.Stdout.WriteLine "Sorry, you gave an invalid response. Good Bye!"
exit do
end if
end if
loop while tryAgain = "yes"
,我有一個loop
沒有do
我的錯誤狀態。
也許你可以縮短你的代碼更一致。這將會更容易解決這些錯誤。 –
非常感謝。我會爲此努力。我仍然是一個小白菜,所以我感謝耐心和回答。 –