input boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    input boxes

    here's a question, how can i use an input box to enter information in a listbox,
    example: lets say i wanted to use a command button to get a inputbox that askes "enter your name" so i would type my name then when i click ok i would like it to be entered in an list box. sorta like transfer my name into the listbox can this be done? and whats the code for doing this or how would i do this

    lee123
  • lee123
    Contributor
    • Feb 2007
    • 556

    #2
    oh i forgot to add address and phone# so now i would like to know how i can put all of these things in an input box to add in a "label" instead of an listbox so when they press the button it would prompt them to add an name then a address then a phone number

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by lee123
      oh i forgot to add address and phone# so now i would like to know how i can put all of these things in an input box to add in a "label" instead of an listbox so when they press the button it would prompt them to add an name then a address then a phone number
      You haven't said what version of VB you're using, so for now I'll assume VB6 (because it's the version I'm familiar with).

      The simplest way would be to use the InputBox() function. This is a pretty ugly function, but it does the job. You can improve the look once you've got a better idea of how to go about it.

      The general technique would be to drop a command button on the form, and in the Click event procedure for the button, add something like...
      [CODE=vb]
      Dim Answer As String
      Answer = InputBox("Enter your name", "Some window title")
      List1.AddItem Answer
      [/CODE]

      Of course, to handle more than one input you can just call the InputBox() function multiple times, to prompt for one after another. But ideally you would want to create your own form with textboxes to accept the name and so on, then just show that. This is one area where VB versions vary quite a bit.

      Comment

      • lee123
        Contributor
        • Feb 2007
        • 556

        #4
        well thanks for the tips, it worked but see how i have that im stuck on something else the reason why i asked that question is that the order form im trying to build isn't working at all i have the button on the form that when i press it the input box askes for the name....and so on and it puts it in the label just like i wanted it to but i have also placed four txtboxes one for the qty,product,uni t price,total. but i don't want just one set of these is there a way to make it a continuious. for instants let say that the customer has several things he is buying how can i do this with just one set of txtboxes or do i add more txtboxes to do this

        Comment

        • lee123
          Contributor
          • Feb 2007
          • 556

          #5
          by the way im using vb 6 thanks
          lee123

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by lee123
            by the way im using vb 6 thanks
            Excellent! In that case, you can use a control array. And that means you can easily add new occurrences to the array(s) at runtime.

            However, you need to consider what is appropriate. If you keep adding textboxes, then you're going to run off the end of the form, then you have to start looking into how you can scroll things around, and it just keeps getting more complicated.

            It'd probably be smarter to look into the various grid controls available in VB.

            Comment

            Working...