I’m new to Visual Basic.
I have a little program look like this.
https://www.dropbox.com/s/xr44pxp3n79atkk/wall.png
It will calculate the total area by adding up all wall area.
Public Sub btnWallAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWallAdd.Click
FlowLayoutPanel1.Controls.Clear()
FlowLayoutPanel1.AutoScroll = True
For i As Integer = 1 To Val(txtWallNo.Text)
Dim Width As New TextBox()
Dim Height As New TextBox()
Width.Name = "Width" & i
Width.Text = Width.Name
Height.Name = "Height" & i
Height.Text = Height.Name
FlowLayoutPanel1.Controls.Add(Width)
FlowLayoutPanel1.Controls.Add(Height)
Next
End Sub
I have successfully create dynamic textbox base on the number entered by user but I don’t know how to get values from those textbox an add them up. Please teach me how do it. Thank you very much!
Sorry for my English!
You can access the controls by name, like this:
Or, if you have option strict turned on, you need to be explicit about the type conversions:
For instance, to add up the area on all the walls, you could do something like this: