Vbscript 为什么此代码会跳过第三个“;否则,如果;在这里

Vbscript 为什么此代码会跳过第三个“;否则,如果;在这里,vbscript,Vbscript,以下代码有什么问题?它跳过了第三个“else if”和“你睡觉了吗?” Dim消息,i 暗淡的strShutdown、lastword、strAbort i=小时(时间) Message=InputBox(“你好,你可能是谁?”,“病毒”) 如果消息=“且i>=8且i=18,然后i=20,然后i=20,或者i=20或i=20,或者i=20或i

以下代码有什么问题?它跳过了第三个“else if”和“你睡觉了吗?”

Dim消息,i
暗淡的strShutdown、lastword、strAbort
i=小时(时间)
Message=InputBox(“你好,你可能是谁?”,“病毒”)
如果消息=“且i>=8且i<12,则
Echo“早上好。”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs”
Elseif Message=“”和i=12然后
Echo“下午好。”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs”
Elseif Message=“”和i>=18,然后i<20
Echo“晚上好”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs”
Elseif Message=“”和i>=20,然后i<8
Echo“你睡觉了吗?”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar”
CreateObject(“WScript.Shell”)。运行“C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs”
其他的
回声“嗯…入侵者嗯…嘿!!”
strShutdown=“shutdown.exe-s-t 60-f”
设置objShell=CreateObject(“WScript.Shell”)
运行strShutdown,0,false
WScript.Sleep 100
lastword=Inputbox(“计算机将在60秒后关闭。有什么遗言吗?”,“病毒”)
如果lastword=“停止”,则
Echo“Hmpf!”
strAbort=“shutdown.exe-a”
设置objShell=CreateObject(“WScript.Shell”)
运行strAbort,0,false
其他的
Echo“对不起,再见”
如果结束
如果结束

此外,我是否可以连接到MS Access,以便为其提供更多种类的回复和它也可以接受的消息?如果您熟悉桌面好友,我想创建一个,并添加一个部分,这样您不仅可以在桌面上与好友互动,还可以与好友聊天。

我认为这是因为elseif条件永远不会成立。我不能同时大于或等于20和小于8。也许你指的是
和i>=20,或者i<8,然后
?此外,我会将它们包括在参数中,以确保逻辑以正确的顺序计算,例如:

Elseif Message = " "  and (i >= 20 or i < 8) then
Elseif Message=”“和(i>=20或i<8)然后

我认为这是因为elseif条件永远不会成立。我不能同时大于或等于20和小于8。也许你指的是
和i>=20,或者i<8,然后
?此外,我会将它们包括在参数中,以确保逻辑以正确的顺序计算,例如:

Elseif Message = " "  and (i >= 20 or i < 8) then
Elseif Message=”“和(i>=20或i<8)然后

在其他位置使用
选择案例

为了方便起见,我对您的代码进行了一些重构:

Dim Message
Dim lastword
Dim i
Dim strShutdown
Dim strAbort

strShutdown = "shutdown.exe -s -t 60 -f"
strAbort = "shutdown.exe -a"

i = Hour (Time)
Message = InputBox("Hello and WHO might you be?","Virus")

if Message = " " then
    Select Case i
        case 8, 9, 10, 11
            WScript.Echo "Good Morning."
        case 12, 13, 14, 15, 16, 17
            WScript.Echo "Good Afternoon."
        case 18, 19
            WScript.Echo "Good Evening."
        case else
            WScript.Echo "Do you even sleep ?"
    end select
    CreateObject ("WScript.Shell").Run """C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar"""
    CreateObject ("WScript.Shell").Run """C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs"""

Else 
    WScript.Echo "Hmm.... Intruder huh... heh!!."

    set objShell = CreateObject("WScript.Shell")
    objShell.Run strShutdown, 0, false
    WScript.Sleep 100

    lastword= Inputbox("Computer will shutdown in 60 seconds. Any last words?" , "Virus")
    If lastword = "stop it" then
        WScript.Echo "Hmpf!"
        set objShell = CreateObject("WScript.Shell")
        objShell.Run strAbort, 0, false
    else
        WScript.Echo "Sorry and Goodbye"
    End if
End if

在其他位置使用
选择案例

为了方便起见,我对您的代码进行了一些重构:

Dim Message
Dim lastword
Dim i
Dim strShutdown
Dim strAbort

strShutdown = "shutdown.exe -s -t 60 -f"
strAbort = "shutdown.exe -a"

i = Hour (Time)
Message = InputBox("Hello and WHO might you be?","Virus")

if Message = " " then
    Select Case i
        case 8, 9, 10, 11
            WScript.Echo "Good Morning."
        case 12, 13, 14, 15, 16, 17
            WScript.Echo "Good Afternoon."
        case 18, 19
            WScript.Echo "Good Evening."
        case else
            WScript.Echo "Do you even sleep ?"
    end select
    CreateObject ("WScript.Shell").Run """C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\Shimeji.jar"""
    CreateObject ("WScript.Shell").Run """C:\Documents and Settings\Admin\My Documents\My Files\Designs\Vocaloid\Miku\hello.vbs"""

Else 
    WScript.Echo "Hmm.... Intruder huh... heh!!."

    set objShell = CreateObject("WScript.Shell")
    objShell.Run strShutdown, 0, false
    WScript.Sleep 100

    lastword= Inputbox("Computer will shutdown in 60 seconds. Any last words?" , "Virus")
    If lastword = "stop it" then
        WScript.Echo "Hmpf!"
        set objShell = CreateObject("WScript.Shell")
        objShell.Run strAbort, 0, false
    else
        WScript.Echo "Sorry and Goodbye"
    End if
End if

这个问题格式很差。请尝试改进您发布的代码的格式。你也应该试着解释你想做什么。另外,请将每个问题保留在各自的主题上,不要将属于不同主题的多个问题包含在同一个问题中。awww。。好的xD哈哈哈对不起xD不需要道歉,我们都是第一次接触StackOverflow。确保你的下一个问题整洁、专业。我试着整理一下,但我认为还需要一些工作才能让它成为一个非常清晰的问题。哇,你们太棒了。。抱歉搞得一团糟。。我仍然是一名学生,正在做自己的实验以获得经验。我保证,我会改进的。谢谢你的帮助,顺便说一句,这个问题的格式非常糟糕。请尝试改进您发布的代码的格式。你也应该试着解释你想做什么。另外,请将每个问题保留在各自的主题上,不要将属于不同主题的多个问题包含在同一个问题中。awww。。好的xD哈哈哈对不起xD不需要道歉,我们都是第一次接触StackOverflow。确保你的下一个问题整洁、专业。我试着整理一下,但我认为还需要一些工作才能让它成为一个非常清晰的问题。哇,你们太棒了。。抱歉搞得一团糟。。我仍然是一名学生,正在做自己的实验以获得经验。我保证,我会改进的。谢谢你的帮助,顺便说一句xDwow真是太快了。。非常感谢。。你知道我的第二个问题吗?xD关于桌面好友?嘿嘿,对不起,我不知道。如果你满意的话,你能接受我的回答吗?我是一个新用户——就像你一样——我正在努力建立我的代表。哇,太快了。。非常感谢。。你知道我的第二个问题吗?xD关于桌面好友?嘿嘿,对不起,我不知道。如果你满意的话,你能接受我的回答吗?我是一个新用户——就像你一样——我正在努力建立我的代表。