在VBScript中,我无法阻止循环重复

时间:2015-10-20 18:20:48

标签: vbscript

我很难解决这个问题,但我很快就会出现问题。

这是我的代码:

'attempts and completions loop
    'attempts
    do
        do
            Wscript.StdOut.WriteLine "How many attempts did " & QB & " throw: "
            attempts = Wscript.StdIn.ReadLine
            if IsNumeric(attempts) then
                attempts = CInt(attempts)
            else
                Wscript.StdOut.Write "You did not enter a number. Please try again."
            end if
        loop while IsNumeric(attempts) = false

        'completions
        do
            Wscript.StdOut.WriteLine "How many completed passes did " & QB & " throw for: "
            completions = Wscript.StdIn.ReadLine
            if IsNumeric(completions) then
                attempts = CInt(completions)
            else
                Wscript.StdOut.Write "You did not enter a number. Please try again."
            end if
        loop while (completions) = false
    if attempts > completions then
        exit do
    else
        Wscript.StdOut.Writeline "Completions can not be more that attempts please try again."
    end if
    loop while attempts < completions

当我输入更多的完成而不是尝试时,我得到了我的欲望结果。但是当我输入更多的尝试而不是完成时,它仍将循环遍历此代码。我可以请一些帮助。

1 个答案:

答案 0 :(得分:0)

没关系我的评论......我现在看到了。在完成的循环中,您应该在设置完成变量时设置尝试变量。

if IsNumeric(completions) then
            attempts = CInt(completions)

因此,当您进行比较时,尝试总是空白或无论您将其初始化为什么。

标准复制/粘贴错误:)