1 Replies - 1041 Views - Last Post: 04 August 2012 - 10:15 PM Rate Topic: -----

#1 tinkerbell20   User is offline

  • New D.I.C Head

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

how to get the values of the dynamic texboxes

Posted 04 August 2012 - 09:19 PM

can someone tell me how to get the values of the dynamic texbox created..on my first code, i munaully put textboxes..but resulted to non efficient code according to my prof..so i found a code that dynamically create texboxes, but my problem now is how to get the values of them. now, i want to get the values so that i can ccalculate it by the non-preemptive priority scheduling rule..so hooooooww :(

    Dim captions() As String = {"Burst Time for Job ", "Priority Number for job "}
    ' Coordinates for the controls.
    Dim y As Integer = 60
    inputjobnumber = Val(txtboxinputnojob.Text)
    For i As Integer = 1 To inputjobnumber
    For Each caption As String In captions
    ' Make the Label.
    Dim new_label As New Label()
    new_label.Parent = Me
    new_label.Text = caption + i.ToString
    new_label.Location = New Point(8, y)
    new_label.AutoSize = True
    ' Make the TextBox.
    Dim new_textbox As New TextBox()
    new_textbox.Parent = Me
    new_textbox.Location = New Point(130, y)
    new_textbox.Name = "txt" & i
    ' Move down.
    y += new_textbox.Height + 4
    Next caption
    y += 10
    Next



Is This A Good Question/Topic? 0
  • +

Replies To: how to get the values of the dynamic texboxes

#2 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: how to get the values of the dynamic texboxes

Posted 04 August 2012 - 10:15 PM

I don't see where you are adding these to the form's control collection. You can loop thru the control collection and search for them. A simple naming convention will help to isolate them from others.

For Each ctr As Control In Me.Controls
  If ctr.Name.StartsWith("txt") Then
    ' it is a dynamic control
    ' get it's value
  End If
Next


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1