首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当我使用select case语句时,为什么要得到一个其他错误&如何修复它?

当我使用select case语句时,为什么要得到一个其他错误&如何修复它?
EN

Stack Overflow用户
提问于 2017-10-20 17:34:49
回答 3查看 48关注 0票数 0

我修改了用于调用多个工作表的代码&我想使用它来调用web地址。

代码语言:javascript
运行
复制
Sub OVR_Office_Listing()
  Dim i As String

'MsgBox prompt:="1st 6 Months of Reports?", Title:="Referral Workbook - Data Entry"
i = MsgBox("Continue to OVR Office Directory?", vbYesNo, " Referral Workbook - Data Entry")

If Not i = vbYes Then Exit Sub

'First message shows in the body of the box, message 2 shows at the top of the box.
Do
    MyValue = Application.InputBox("Only Click Ok or Cancel after your Selection!!!!!!!" & vbCrLf & _
                           "1 = OVR Office Directory" & vbCrLf & _
                           "2 = BBVS (Bureau of Blindness & Visual Services)Office Directory", "Walk In Training Data Entry")
    ' Sub messaage box exit.
    If MyValue = False Then
        Exit Sub
    ElseIf (MyValue = 1) Or (MyValue = 2) Then
        Exit Do
    Else
        MsgBox "You have not made a valid entry.  Please try again.", vbInformation, "Referral Workbook - Data Entry"
    End If
Loop    'Code to Execute When Condition = value_1

Select Case MyValue
    Case 1
           ' The message below only shows when you are on the active sheet.
                    MsgBox "You are already on OVR Office Directory!", vbInformation, "Referral Workbook - Data Entry"
                Else
                Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE "http://www.dli.pa.gov/Individuals/Disability-Services/bbvs/Pages/BBVS-Office-Directory.aspx"
ie.Visible = True
End Select
                End If
    'Code to Execute When Condition = value_2
    Case 2

           ' The message below only shows when you are on the active sheet.
                    MsgBox "You are already on Bureau of Blindness & Visual Services Office Directory!", vbInformation, "Referral Workbook - Data Entry"
                Else
                  Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE "http://www.dli.pa.gov/individuals/disability-services/ovr/pages/OVR-office-directory.aspx"
ie.Visible = True
End Select

                End If
End Select
End Sub

我得到一个编译错误:否则,如果。错误发生在以下情况:大小写1‘下面的消息仅显示在活动工作表上。MsgBox“您已经在OVR办公目录上了!”,vbInformation,"Referral Workbook - Data Entry" on OVR。你能做我想做的事吗?我错过了什么。我确实有一个Select ,它看起来不够或者在错误的位置。请告诉我我做错了什么。

EN

回答 3

Stack Overflow用户

发布于 2017-10-23 18:37:38

问题解决了。

代码语言:javascript
运行
复制
      `Sub OVR_Office_Listing()
      Dim i As String
     'MsgBox prompt:="1st 6 Months of Reports?", Title:="Referral Workbook - Data  Entry"
     i = MsgBox("Continue to OVR Directories?", vbYesNo, " Referral Workbook - Data Entry")

   If Not i = vbYes Then Exit Sub

   'First message shows in the body of the box, message 2 shows at the top of the box.

   Do
   MyValue = Application.InputBox("Only Click Ok or Cancel after your  Selection!!!!!!!" & vbCrLf & _
                       "1 = OVR Office Directory" & vbCrLf & _
                       "2 = BBVS (Bureau of Blindness & Visual Services)    Office Directory", "Walk In Training Data Entry")
 'Sub messaage box exit.
 If MyValue = False Then
    Exit Sub
 ElseIf (MyValue = 1) Or (MyValue = 2) Then
    Exit Do
 Else
 MsgBox "You have not made a valid entry.  Please try again.",  vbInformation, "Referral Workbook - Data Entry"
 End If

 Loop
'Code to Execute When Condition = value_1
Select Case MyValue
Case 1
'Message prior to calling the webb address.
                MsgBox "Please wait, while get you the OVR web address.", vbInformation, "Referral Workbook - Data Entry"

            Dim ie As Object
Set ie1 = CreateObject("INTERNETEXPLORER.APPLICATION")
ie1.NAVIGATE "http://www.dli.pa.gov/individuals/disability- services/ovr/pages/OVR-office-directory.aspx"
ie1.Visible = True
 'Code to Execute When Condition = value_2
Select Case MyValue
 End Select
 Case 2

       'Message prior to calling the webb address.
                MsgBox "Please wait, while I get you the Bureau of Blindness & Visual Services Office Directory!", vbInformation, "Referral Workbook - Data Entry"
            'Else
              Dim ie2 As Object
  Set ie2 = CreateObject("INTERNETEXPLORER.APPLICATION")
  ie2.NAVIGATE "http://www.dli.pa.gov/Individuals/Disability-Services/bbvs/Pages/BBVS-Office-Directory.aspx"
  ie2.Visible = True
  End Select
 End Sub`
票数 1
EN

Stack Overflow用户

发布于 2017-10-20 17:37:20

将该Else更改为Case ElseElse本身需要一个匹配的If语句。

票数 0
EN

Stack Overflow用户

发布于 2017-10-20 17:51:10

试着使用下面的代码。

代码语言:javascript
运行
复制
Sub OVR_Office_Listing()
  Dim i As String

'MsgBox prompt:="1st 6 Months of Reports?", Title:="Referral Workbook - Data Entry"
i = MsgBox("Continue to OVR Office Directory?", vbYesNo, " Referral Workbook - Data Entry")

If Not i = vbYes Then Exit Sub

'First message shows in the body of the box, message 2 shows at the top of the box.
Do
    MyValue = Application.InputBox("Only Click Ok or Cancel after your Selection!!!!!!!" & vbCrLf & _
                           "1 = OVR Office Directory" & vbCrLf & _
                           "2 = BBVS (Bureau of Blindness & Visual Services)Office Directory", "Walk In Training Data Entry")
    ' Sub messaage box exit.
    If MyValue = False Then
        Exit Sub
    ElseIf (MyValue = 1) Or (MyValue = 2) Then
        Exit Do
    Else
        MsgBox "You have not made a valid entry.  Please try again.", vbInformation, "Referral Workbook - Data Entry"
    End If
Loop    'Code to Execute When Condition = value_1

Select Case MyValue
    Case 1
           ' The message below only shows when you are on the active sheet.
                    MsgBox "You are already on OVR Office Directory!", vbInformation, "Referral Workbook - Data Entry"
    Case 2
                Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE "http://www.dli.pa.gov/Individuals/Disability-Services/bbvs/Pages/BBVS-Office-Directory.aspx"
ie.Visible = True
'End Select
                'End If
    'Code to Execute When Condition = value_2
    Case 3

           ' The message below only shows when you are on the active sheet.
                    MsgBox "You are already on Bureau of Blindness & Visual Services Office Directory!", vbInformation, "Referral Workbook - Data Entry"
                'Else
                  Dim ie2 As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie2.NAVIGATE "http://www.dli.pa.gov/individuals/disability-services/ovr/pages/OVR-office-directory.aspx"
ie2.Visible = True
End Select
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46854428

复制
相关文章

相似问题

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