0

次のコードの何が問題になっていますか? 3 番目の「else if」は「Do you even sleep?」とスキップします。

      Dim Message, i
  Dim strShutdown , lastword, strAbort

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

if Message = " "  and i >= 8 and i < 12 then
WScript.Echo "Good Morning."
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"""

Elseif Message = " " and i <= 17 and i >= 12 then
WScript.Echo "Good Afternoon."
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"""

Elseif Message = " "  and i >= 18 and i < 20 then
WScript.Echo "Good Evening."
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"""

Elseif Message = " "  and i >= 20 and i < 8 then
WScript.Echo "Do you even sleep ?"
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!!."
strShutdown = "shutdown.exe -s -t 60 -f"
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!"
strAbort = "shutdown.exe -a"
set objShell = CreateObject("WScript.Shell")
objShell.Run strAbort, 0, false
else
WScript.Echo "Sorry and Goodbye"
End if
End if

また、MS Access に接続して、より多くの種類の返信やメッセージを受け取ることはできますか? Desktop Buddies に慣れている場合は、デスクトップ Buddies を作成して、デスクトップで操作できるだけでなく、チャットもできる部分を追加したいと思います。

4

2 に答える 2

4

そのelseif条件が真になることは決してないからだと思います。i を同時に 20 以上かつ 8 未満にすることはできません。多分あなたは意味しましたand i >= 20 OR i < 8 thenか?また、ロジックが正しい順序で計算されていることを確認するために、それらを括弧に含めます。

Elseif Message = " "  and (i >= 20 or i < 8) then
于 2013-08-27T16:33:36.327 に答える
2

select caseat elseを使用する

便宜上、コードを少しリファクタリングしました。

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
于 2013-08-27T16:50:06.070 に答える