Say I've got the following variables:
Public Shared x As String = "100"
Public Shared y As String = "text"
Public Shared z As String = "something"
And I got a function:
Function giveVar(ByVal varName As String) As String
Return varName
End Function
But this doesn't do what I want, naturally. What I want is that my function giveVar
returns the value of the variable that holds giveVar
. For example I call giveVar("x")
I want my function to return "100"
.
Of course this can be done by a Select Case
but thats not what I like to do. Does anyone has any suggestion?
Is it even possible to call a value based on a string?
[edit:]
Namespace i18n
public NotInheritable Class Settings
Public Shared LanguageCode As String
Public Shared HideAllLocalizedText As Boolean
End Class
Public NotInheritable Class i18n
Private Sub New()
End Sub
Public Shared Function t(ByVal varName As String) As String
Select Case Settings.LanguageCode
Case "en"
Return en(varName)
Case Else
Return nl(varName)
End Select
End Function
Private Shared Function en(ByVal varName As String) As String
Dim ASP_0344 As String = "Cancel"
Dim ASP_0807 As String = "Click"
Dim ASP_0808 As String = "here"
Dim ASP_0812 As String = "Welcome at the login screen..."
' These are examples there is a whole bigger list
Return CallByName(Me, varName, vbGet)
End Function
Private Shared Function nl(ByVal varName As String) As String
Dim ASP_0344 As String = "Annuleren"
Dim ASP_0807 As String = "Klik"
Dim ASP_0808 As String = "hier"
Dim ASP_0812 As String = "Welkom op het inlogscherm..."
Return CallByName(Me, varName, vbGet)
End Function
End Class
End Namespace
I think this works so far, BUT I get the following error on the CallByName(Me, varName, vbGet)
at the Me
: "me is only valid within an instance method"