Alternative to GoSub in VB.net

限于喜欢 提交于 2019-12-02 03:59:54

Based on my comments above, your code should look like this:

Sub Main ()
  Dim A As String

  If ConditionX Then A = "Black"
  Else A = "White"
  End If
  ...
  Execute(A)
  ...

End Sub

Sub Execute(A As SomeType)
   ...
   BuiltInSub1(A)
   BuiltInSub2(A)
   ...
End Sub

If you do find that you need declare parameters ByRef, you might want to look at refactoring as a more long-term solution.

I believe that lamda functions may have nested variable scope) in VB.net

Dim A
Dim B
Dim xecute = function()
    BuiltInSub1(A)
    BuiltInSub2(A)
End Sub
A = 1
B=xecute()
A=2
B=xecute()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!