首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GoTo“预期语句”

GoTo“预期语句”
EN

Stack Overflow用户
提问于 2017-04-19 06:33:21
回答 3查看 12.8K关注 0票数 0

我正在尝试使用GoTo命令(我不知道有任何替代方法,它在批处理中运行良好)。每当我试图加载程序时,我都会得到这样的错误:

这里基本上就是错误所在(第11行,第3列)

代码语言:javascript
复制
top:
input = InputBox("Enter normal text:", "Message Encrypt Style 2", "Text goes here")
If input = "" Then
    Y = MsgBox("You inputed nothing!", vbRetryCancel+64, "Huh?")
    If Y = 2 Then
        WScript.Quit
    Else
        If Y = 4 Then
            GoTo top
        Else
            If input = 2 Then
                WScript.Quit
EN

回答 3

Stack Overflow用户

发布于 2017-04-19 15:59:22

VBScript没有Goto语句,而且还有一种更简洁的方法。

代码语言:javascript
复制
Do
    input = InputBox(...)

    If IsEmpty(input) Or input = "2" Then
        WScript.Quit
    ElseIf input = "" Then
        MsgBox "No input."
    End If
Loop Until input <> ""
票数 1
EN

Stack Overflow用户

发布于 2017-04-19 08:53:29

尝尝这个

代码语言:javascript
复制
Option Explicit

Dim Input ' as string
Dim Y ' as msgbox response

Input = ""

Do Until Input <> ""
    Input= InputBox("Enter normal text:", "Message Encrypt Style 2", "Text goes here")

    If Input = "" Then
        Y = Msgbox ("You input nothing", vbRetryCancel, "Huh?")
        If Y = vbCancel Then
            WScript.Quit
        End If
    ElseIf Input = "2" Then
        WScript.Quit
    End If  
Loop

' Proceed here if input is valid
票数 0
EN

Stack Overflow用户

发布于 2018-06-21 20:43:55

Vbscript是一种结构化编程语言,结构化编程的主要目标之一是消除goto语句的considered harmful。Vbscript确实有一个用于异常的goto,但这些只用于在程序退出之前的资源清理。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43483302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档