0

I have:

Dim some340id, some341id, someCDFid, someARCid, some8FGid etc... as String

Need to find:

Dim idtofind as String = "ARC"

something like:

Dim Found As String = some{idtofind}id

How to write code for this?

1
  • This is not VBA code, nor is there any such thing as VBA 2015. This is probably VB.NET. You should tag your question correctly, then the right people will see it. The .NET Framework has possibilities not available in VBA. Commented Apr 30, 2016 at 22:40

2 Answers 2

0

Although VB is an interpreter, I don't know if you can do this. But what you can do is use an array and index that with a meaningful Const name, for example:

Private Const i340id As Integer = 0
Private Const i341id As Integer = 1
...
Private Const iMAXid As Integer = 99

Dim some(iMAXid) As String

MsgBox "String is " & some(i341id)
Sign up to request clarification or add additional context in comments.

Comments

0

@Paul, not working ("String is " empty), but i try to mod Your solution and now it's working. Much thank You.

Public Const incoming340id As Integer = 0
    Public Const incoming341id As Integer = 1
    Public Const incomingMAXid As Integer = 99

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim some As String = 341

    MsgBox("String is " & "incoming" & some.ToString & "id")
End Sub

Now how to result change to working variable?

Dim somethingNew as String = "incoming" & some.ToString & "id"

I have somethingNew, and want to worki it like variable incoming341id

incoming341id = otherResult.Text

but now i have "somethingNew"...

1 Comment

Seems you didn't get the idea: you CANNOT get the name of a variable programmatically. Instead, use an array that repesent the variables and use indexes that are constats with meaningful names. And Dim some As String = 341 won't work as you cannot initialize a variable in VB, only constants. See stackoverflow.com/questions/18336006/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.