English 中文(简体)
提前结束案件
原标题:Ending a Case Early

所以我在Vb6里有类似的东西

Select case Case

case "Case0"
...

case "Case1"
  if Condition Then
     Exit Select
  End If
  *Perform action*

case "Case2"
...

End Select

但出于某种原因,我的 < code> Exit select 丢弃错误 < code> exect < exect > expect < code > accept: do or for or For或 Sub或函数或属性 。 我知道, 不漂亮 。 我是否应该使用其它东西? 我可以使用 < code> if 的语句, 而不是提前退出此语句, 但这需要重复的代码, 我想避免它。 任何帮助都会非常感激 。

<强 > 更新

尝试将 Exit select 改为 End select ,并获得错误 End select 没有选择案例 。 它绝对在 选择案例 End 选择 之内。

最佳回答

VB doesn t have a facility to exit a Select block. Instead, you ll need to make the contents conditional, possibly inverting your Exit Select conditional.

Select case Case 

case "Case0" 
... 

case "Case1" 
  If Not Condition Then 
    *Perform action* 
  End If 

case "Case2" 
... 

End Select 

这将产生完全相同的最终结果。

问题回答

VB6 - 只有 VB.NET 没有 Exit select 语句

请查看 的语种参考 http://msdn.microsoft.com/ en- us/library/aa243366%28v=vs. 60%29.aspx" rel= "noreferr" >Exit 声明 - 有 no 提到 Exit 选择

最佳选项是将您选择的语句重构成一个新的子例程, 然后仅 Exit Sub

不幸的是, VB6 没有提供 < code> Exit select 条款 。

这是在VB.NET的网上提供!

试试这个

Do
    Select case Case

    case "Case0"
    ...

    case "Case1"
      if Condition Then
         Exit Do
      End If
      *Perform action*

    case "Case2"
    ...

    End Select
Loop While False

编辑: Btw, 在此情况下, 我将犹豫使用 < code> GoTo (不仅如此) 。

回答这个老问题,你也可以用另一种方式使用 GoTo:

Select case Case

case "Case0"
...

case "Case1"  you can use not condition as stated

  if Condition Then GoTo Exit_select
  *Perform action*

case "Case2"
...
Exit_select:
End Select

刚刚发现了一些微不足道的东西 就能把戏:

Select case Case 

case "Case0" 
... 

case "Case1" 
  A=A

case "Case2" 
... 

End Selec

总是有 总是必须跳到标签 在最后。





相关问题
Prevent windows from queuing shellexecute requests

Win.ShellExecute 0, "open", "C:dirprogram.exe", "arguments", vbNullString, SW_SHOWNORMAL Win.ShellExecute 0, "open", "http://www.google.com", vbNullString, vbNullString, SW_SHOWNORMAL I want google....

Why is My Loop Only Deleting One File?

Using VB6 In a folder, i have n number of files, i want to delete a 0 kb files code Dim filename5 As String filename5 = Dir$(txtsourcedatabasefile & "*_*", vbDirectory) MsgBox filename5 Do ...

How to check the filesize?

Using VB6 I have the text file with different sizes, so i want to delete the file where filesize = 0 kb. How to make a vb6 code for deleting the 0 kb files. Need vb6 code Help

File Rename problem?

I m using VB6 and I have a folder where I have n number of files. I want to change the file extension to .txt. I used the code below to change the extension of all .fin files to .txt. Dim filename1 ...

Error 20728-F while in using Crystal Reports in VB6

I m using Crystal Reports in my VB6 project, but I m facing error while loading the report in crystalreport1.action=1; Please give me some solution for this problem. It is showing the error as Error ...

DllRegisterServer entry point was not found

When running my vb6 application I am getting error like, runtime error 53 : file not found: rscomclNoMsg.dll then i tried to register that dll from cmd line using regsvr32. Then I am getting ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签