Based on input number Creating textboxes and lablel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • huskar
    New Member
    • Mar 2012
    • 6

    Based on input number Creating textboxes and lablel

    Hi everyone!
    i am newbie to visual basic.net, and I'm having a headache to do this. Assuming we ask the user to input a number of guests and based on that number of guests..we creating textbox or label or something to ask guests' name, guests' age.
    For Example:
    User will put in our textbox 2 guests so we will firt ask for the first guest what is his name, what is his age and then ask for the second guests what is his name, what is his age. I wonder how we can design a form to ask for this since the guests that user put in is unknown until the users tell us. (how many textbox and lable we have to implement in our form for guests' name, guests' age since we do not know how many guests will be)
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    This call in VB6 creates commands at runtime: "How to create buttons dynamically inside grid element".
    Just set an element with index = 0 in the form and LOAD a number of this elements at runtime.
    Use the index to identify and work with them.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      I'm pretty sure MS did away with control arrays in VB.Net.

      Comment

      • huskar
        New Member
        • Mar 2012
        • 6

        #4
        Thank all!! i got an idea but a brand new problem :(

        Comment

        • rekedtechie
          New Member
          • Feb 2012
          • 51

          #5
          Code:
          'this can be done by using string arrays
          
          'put variables in your global declaration
          Dim x As Integer
          Dim n As Integer = 0
          Dim strNames[] As String
          
          'put this code in your command button to set number of Guest
          x = txtboxGuestNumber.Text
          
          'put this code in your command button to add name.
          If n = x Then
          msgbox "Guest limit occured!"
          else
          strNames[n] = txtName.text
          n = n+1
          End If
          
          'put this code in command button to view arrays
          For i = 0 to x
          Debug.Print strNames[i]
          Next i
          
          'good luck! =)

          Comment

          Working...