2 Replies - 4605 Views - Last Post: 08 August 2012 - 04:05 AM Rate Topic: -----

#1 musicazx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-August 12

How to get Values from Dynamic generated Textbox

Posted 06 August 2012 - 04:41 AM

I'm new to Visual Basic.
I have a little program look like this.
Posted Image <Please have a look


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!

https://www.dropbox....79atkk/wall.png

Is This A Good Question/Topic? 0
  • +

Replies To: How to get Values from Dynamic generated Textbox

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: How to get Values from Dynamic generated Textbox

Posted 08 August 2012 - 03:33 AM

I suggest you store every created Width and Height object pair into Hashtable, and on "Calculate Wall Area" button.click event, loop thorugh each DictionaryEntry key/value pair in Hashtable, and calculate the area.
Was This Post Helpful? 0
  • +
  • -

#3 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: How to get Values from Dynamic generated Textbox

Posted 08 August 2012 - 04:05 AM

If You really don't know how to do what I suggested, here is the code:

Spoiler

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1