Emree
Emree

Reputation: 85

Vb.net combobox name issue

I want to concat two strings and I need the name of a combo box to be the result of concatenation. For example,

parametre = hi

parametre2 = everyone

I have put name hieveryone my combobox name

parametre3 = String.Concat(parametre,parametre2)

dim parametre3 as ComboBox

How can I do solve this problem?

Upvotes: 0

Views: 91

Answers (2)

J0HN
J0HN

Reputation: 26941

Dim parameter1 As New String("Hi");
Dim parameter2 As New String("everyone");
Dim combo As New ComboBox();
combo.Name = String.Concat(parameter1, parameter2);

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500575

You can't do this. Variable naming occurs at compile time, whereas the string concatenation occurs at execution time.

Generally, if you want to dynamically map strings to values, you should use a Dictionary(Of String, Of ComboBox) or whatever. Then you can put values into the dictionary by string key, and retrieve them later.

Upvotes: 2

Related Questions