Is there a way to call a procedure in Visual Basic (.net) with a variable name?
For example, the variable strColour can be one of 10 pre-defined values, green blue black white red pink orange yellow indigo purple. How to handle each one is in it's own Sub Routine, colgreen, colblue, colblack and so on.
I can use a bunch of if..then..else and select case, but what I'd like to have is something like VBA Excel's Run "col" & strColour
Is it possible?
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "one"
CallByName(Me, s, CallType.Method) 'Subs must be public
s = "two"
CallByName(Me, s, CallType.Method) 'Subs must be public
End Sub
Public Sub one()
Stop
End Sub
Public Sub two()
Stop
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With