You can't - VB does not support pointers.
Instead, consider using a Dictionary:
Dim dict As New Dictionary(Of String, Integer)()
dict.Add("Variable1", 0)
dict.Add("Variable2", 1)
dict.Add("Variable3", 2)
Dim i As Integer = dict("Variable2") + dict("Variable3")
Console.WriteLine(i)
""thanks but You misunderstood me - surely becasue of names in array. :) i haven't in my mind sum as math function. :) there also can be positions like:
boat1
boat2
boat3
Ah! If I understand you you want to read strings from an array, and create a variable with the name of the value in the string? You can do that, using Reflection, but it is a cumbersome sledgehammer to crack what it probably a simple nut, because your variable names will not be available as compile time, so they will be as difficult to use as they are to create.
Why do you want to do that?
Private Sub new_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles new_button.Click
Dim aa As Integer
aa = new_text_box.Text
aa = aa + 1
new_text_box.Text = aa
End Sub
"I've published the same code in other question, so i'm sorry for duplicates.
The problem is that when I click on any button only value in bottom textbox is raising. As you know the target is to raise up value in text box on the left of button..."
Ah! That makes it easy!
You don't need to worry about names, you just need to get the correct instance. Fortunately, every Event passes you the object that raised the event as the
sender
parameter:
Private Sub new_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles new_button.Click
Dim t As TextBox = TryCast(sender, TextBox)
If t IsNot Nothing Then
Dim aa As Integer
aa = t.Text
aa = aa + 1
t.Text = aa
End If
End Sub
Edit - I just realized...
The event is a Button event, so it won't work quite like that.
Add a line of code to your
frmDoPakowania_Shown
function:
AddHandler new_button.Click, AddressOf Me.new_button_Click
new_button.Tag = new_text_box '****** ADD THIS
Me.Controls.Add(new_button)
Then change the function to use a button, and it's Tag property:
Private Sub new_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles new_button.Click
Dim b as Button = TryCast(sender, Button)
If b IsNot Nothing Then
Dim t As TextBox = TryCast(b.Tag, TextBox)
If t IsNot Nothing Then
Dim aa As Integer
aa = t.Text
aa = aa + 1
t.Text = aa
End If
End If
End Sub
The Tag property is something each control has, and is available for you to put an object into. In this case, each button is concerned with a specific TextBox, so we tell the button which box to refer to.
[edit]DOH! Replaced
new_text_box.Text
with
t.Text
- OriginalGriff[/edit]