Vbscript 我的VBS上缺少什么语句?我能';我找不到。它说41行中的声明缺失

Vbscript 我的VBS上缺少什么语句?我能';我找不到。它说41行中的声明缺失,vbscript,Vbscript,尝试在线使用此工具缩进代码: 为了更好地阅读和调试您的问题: X=inputbox("Hello there (Hello/Hi/What's up?)") If X = "Hello" Then X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)") ElseIf X = "hello" Then X=inputbox("What's up?? (Feeling Awesome/Feeli

尝试在线使用此工具缩进代码:

为了更好地阅读和调试您的问题:

X=inputbox("Hello there (Hello/Hi/What's up?)")

If X = "Hello" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "hello" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "Hi" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "hi" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

End If

If X = "Feeling Awesome" Then

   X=inputbox("Great! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "Feeling Normal" Then

   X=inputbox("Okay! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "Feeling Sad" Then

   X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play 
Question and Answer with Yes and No? (Yes/No)?")

ElseIf X = "feeling awesome" Then

   X=inputbox("Great! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "feeling normal" Then

   X=inputbox("Okay! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X - "feeling sad" Then

   X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play 
Question and Answer with Yes and No? (Yes/No)?")

End If

If X = "Yes" Then

B=Msgbox("Do you have secrets?",vbYesNo+vbQuestion)

If B = vbYes Then

B=MsgBox("Are they super secrets that only you know, Or they also know your best 

friend(s)?",vbYesNo+vbQuestion)

ElseIf B = vbNo Then

B=MsgBox("Great that means you are a nice guy.",vbInformation)

B = MsgBox("Do you have a Sister/Brother?",vbYesNo+vbQuestion)

If B = vbYes Then

A = inputbox("What's his/her name?")

B = msgbox("From now my favorite name is" + A)

ElseIf B = vbNo Then

B = MsgBox ("Okay then!")

B = MsgBox("Is Ice Cream better than Chocolate?",vbYesNo+vbQuestion)

If B = vbYes Then

B = MsgBox("But for me chocolates are much better")

ElseIf B = vbNo Then

B = MsgBox("Cool I like for me chocolates are better too.")

EndIf

ElseIf Y = vbNo Then

msgBox("Bye!")

EndIf

尝试在线使用此工具缩进代码:

为了更好地阅读和调试您的问题:

X=inputbox("Hello there (Hello/Hi/What's up?)")

If X = "Hello" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "hello" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "Hi" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

ElseIf X = "hi" Then

   X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")

End If

If X = "Feeling Awesome" Then

   X=inputbox("Great! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "Feeling Normal" Then

   X=inputbox("Okay! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "Feeling Sad" Then

   X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play 
Question and Answer with Yes and No? (Yes/No)?")

ElseIf X = "feeling awesome" Then

   X=inputbox("Great! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X = "feeling normal" Then

   X=inputbox("Okay! Can we play Question and Answer with Yes and No? 
(Yes/No)?")

ElseIf X - "feeling sad" Then

   X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play 
Question and Answer with Yes and No? (Yes/No)?")

End If

If X = "Yes" Then

B=Msgbox("Do you have secrets?",vbYesNo+vbQuestion)

If B = vbYes Then

B=MsgBox("Are they super secrets that only you know, Or they also know your best 

friend(s)?",vbYesNo+vbQuestion)

ElseIf B = vbNo Then

B=MsgBox("Great that means you are a nice guy.",vbInformation)

B = MsgBox("Do you have a Sister/Brother?",vbYesNo+vbQuestion)

If B = vbYes Then

A = inputbox("What's his/her name?")

B = msgbox("From now my favorite name is" + A)

ElseIf B = vbNo Then

B = MsgBox ("Okay then!")

B = MsgBox("Is Ice Cream better than Chocolate?",vbYesNo+vbQuestion)

If B = vbYes Then

B = MsgBox("But for me chocolates are much better")

ElseIf B = vbNo Then

B = MsgBox("Cool I like for me chocolates are better too.")

EndIf

ElseIf Y = vbNo Then

msgBox("Bye!")

EndIf

它是
End If
而不是
EndIf
并且(在您的情况下)每个
If
都需要
End If
。仔细缩进将有助于确定在何处添加缺少的
End Ifs
。我怀疑“机械”压头是否会按您的预期方式格式化代码

更新wrt关于什么代码导致什么错误的推测:

X=inputbox("Hello there (Hello/Hi/What's up?)")
If X = "Hello" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "hello" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "Hi" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "hi" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
End If
If X = "Feeling Awesome" Then
    X=inputbox("Great! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "Feeling Normal" Then
    X=inputbox("Okay! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "Feeling Sad" Then
    X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "feeling awesome" Then
    X=inputbox("Great! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "feeling normal" Then
    X=inputbox("Okay! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X - "feeling sad" Then
    X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play Question and Answer with Yes and No? (Yes/No)?")
End If

If X = "Yes" Then
    B=Msgbox("Do you have secrets?",vbYesNo+vbQuestion)
    If B = vbYes Then
        B=MsgBox("Are they super secrets that only you know, Or they also know your best friend(s)?",vbYesNo+vbQuestion)
    ElseIf B = vbNo Then
        B=MsgBox("Great that means you are a nice guy.",vbInformation)
        B = MsgBox("Do you have a Sister/Brother?",vbYesNo+vbQuestion)
    End If
    If B = vbYes Then
        A = inputbox("What's his/her name?")
        B = msgbox("From now my favorite name is" + A)
    ElseIf B = vbNo Then
        B = MsgBox ("Okay then!")
        B = MsgBox("Is Ice Cream better than Chocolate?",vbYesNo+vbQuestion)
    End If  
    If B = vbYes Then
        B = MsgBox("But for me chocolates are much better")
    ElseIf B = vbNo Then
        B = MsgBox("Cool I like for me chocolates are better too.")             
    ElseIf Y = vbNo Then    
        msgBox("Bye!")  
    End If
End If  

编译错误必须在运行时错误发生之前更正。

如果
而不是
EndIf
,则为
End,并且(在您的情况下)每个
If
都需要
End If
。仔细缩进将有助于确定在何处添加缺少的
End Ifs
。我怀疑“机械”压头是否会按您的预期方式格式化代码

更新wrt关于什么代码导致什么错误的推测:

X=inputbox("Hello there (Hello/Hi/What's up?)")
If X = "Hello" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "hello" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "Hi" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
ElseIf X = "hi" Then
    X=inputbox("What's up?? (Feeling Awesome/Feeling Normal/Feeling Sad)")
End If
If X = "Feeling Awesome" Then
    X=inputbox("Great! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "Feeling Normal" Then
    X=inputbox("Okay! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "Feeling Sad" Then
    X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "feeling awesome" Then
    X=inputbox("Great! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X = "feeling normal" Then
    X=inputbox("Okay! Can we play Question and Answer with Yes and No? (Yes/No)?")
ElseIf X - "feeling sad" Then
    X=inputbox("Oh no! Maybe playing a game will make you happy. Can we play Question and Answer with Yes and No? (Yes/No)?")
End If

If X = "Yes" Then
    B=Msgbox("Do you have secrets?",vbYesNo+vbQuestion)
    If B = vbYes Then
        B=MsgBox("Are they super secrets that only you know, Or they also know your best friend(s)?",vbYesNo+vbQuestion)
    ElseIf B = vbNo Then
        B=MsgBox("Great that means you are a nice guy.",vbInformation)
        B = MsgBox("Do you have a Sister/Brother?",vbYesNo+vbQuestion)
    End If
    If B = vbYes Then
        A = inputbox("What's his/her name?")
        B = msgbox("From now my favorite name is" + A)
    ElseIf B = vbNo Then
        B = MsgBox ("Okay then!")
        B = MsgBox("Is Ice Cream better than Chocolate?",vbYesNo+vbQuestion)
    End If  
    If B = vbYes Then
        B = MsgBox("But for me chocolates are much better")
    ElseIf B = vbNo Then
        B = MsgBox("Cool I like for me chocolates are better too.")             
    ElseIf Y = vbNo Then    
        msgBox("Bye!")  
    End If
End If  

必须先更正编译错误,然后才能发生运行时错误。

错误的原因是不正确的条件

48800410-1.vbs

If X Then
   WScript.Echo "EndIf throws 'Expected statement' error"
EndIf

output:

cscript 48800410-1.vbs
...\48800410-1.vbs(3, 1) Microsoft VBScript compilation error: Expected statement

48800410-2.vbs

If False Then
   WScript.Echo "Trying to substract string throws a type mismatch error"
ElseIf X - "feeling sad" Then
   WScript.Echo "xxx"
End If

cscript 48800410-2.vbs
...\48800410-2.vbs(3, 1) Microsoft VBScript runtime error: Type mismatch: '[string: "feeling sad"]'
这是一个不完整的语句,因为
If
语句条件需要计算为布尔(
True
False
)结果

尝试修正陈述

ElseIf X - "feeling sad" Then
可能会给你一个

预期结果


由于以下原因导致的错误

错误的原因是不正确的条件

48800410-1.vbs

If X Then
   WScript.Echo "EndIf throws 'Expected statement' error"
EndIf

output:

cscript 48800410-1.vbs
...\48800410-1.vbs(3, 1) Microsoft VBScript compilation error: Expected statement

48800410-2.vbs

If False Then
   WScript.Echo "Trying to substract string throws a type mismatch error"
ElseIf X - "feeling sad" Then
   WScript.Echo "xxx"
End If

cscript 48800410-2.vbs
...\48800410-2.vbs(3, 1) Microsoft VBScript runtime error: Type mismatch: '[string: "feeling sad"]'
这是一个不完整的语句,因为
If
语句条件需要计算为布尔(
True
False
)结果

尝试修正陈述

ElseIf X - "feeling sad" Then
可能会给你一个

预期结果


由缩进代码引起的错误,答案应该出现。看起来你打开的“如果”比关闭的多。更容易的是,
ElseIf X-“感到悲伤”可能会实现什么,它是否意味着
ElseIf X=“感到悲伤”那么可能?如果没有计算为布尔值的条件,则该语句不完整。请缩进代码,然后显示答案。看起来你打开的“如果”比关闭的多。更容易的是,
ElseIf X-“感到悲伤”可能会实现什么,它是否意味着
ElseIf X=“感到悲伤”那么可能?如果没有计算为布尔值的条件,则该语句是不完整的。这是如何解决问题的,缺少/不完整的语句仍然存在
ElseIf X-“感到悲伤”然后
?这是如何解决问题的,缺少/不完整的语句仍然存在
ElseIf X-“感到悲伤”然后
?这将产生“预期结束”或“如果没有结束则阻塞如果”错误。但值得注意的是,
EndIf
也会导致它失败。可能是一个
If…ElseIf X-“”…EndIf
组合在一起?(在
EndIf
中缺少空格是故意的)。这会产生“预期结束”或“如果没有结束则阻塞”错误。但值得注意的是
EndIf
也会导致失败。可能是
If…ElseIf X-“…EndIf
的组合?(在
EndIf
中缺少空格是故意的)。啊!我总是打字-除了=啊!我总是打字,除了=