Display values in a ComboBox?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ardhuru
    New Member
    • Dec 2007
    • 4

    Display values in a ComboBox?

    Hello, I am a complete newbie with VB, so this question might sound really stupid; please bear with me.

    My question is, can a combo box be used to display a value in the sense a label can?

    I have developed a piece of hardware (PIC based) that I have connected to the PC over the serial port. Now, I get time from the PIC in an HH:MM format, which I would like to display in 2 combo boxes with dropdown lists; is this possible? Try as I might, I have not been able to do this, although of course I can successfully display those values in a label.

    The reason I would like to display them in the combo list is that I would like to be able to change the value (using hours and minutes from the 2 combos with dropdown lists for hours and minutes) and write back into the PIC; this second part I think I can achieve, if I manage to get the original problem sorted.

    Is this possible at all? Can one write to a combo list?

    I would really appreciate any advise here.

    Thanks and Regards,

    Anand
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    to items to the combobox try this

    combo1.additem "item to add"

    hope that helps you in solving problem.

    Comment

    • ardhuru
      New Member
      • Dec 2007
      • 4

      #3
      Thanks for the prompt reply, Debasis.

      I get a "Method or data member not found".

      I'm sure I'm doing something intrinsically foolish here .....

      Suppose doing runtime, I get a vale of,say, 10, for a variable.

      How do I get the combobox to show the '10'?

      STARTHR.AddItem 10 or STARTHR.AddItem "10" both give me the above error.

      Regards,

      Anand

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Are you sure STARTHR is a combobox only , not any other control ?

        Comment

        • ardhuru
          New Member
          • Dec 2007
          • 4

          #5
          Yes it is. But, I had copied and pasted this from something I had written a *long* time ago, and I think its an array; the properties shows the name as STARTHR(0).

          Does this make sense? How can I change this to be a simple non-array?

          Regards,

          Anand

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            try this

            STARTHR(0).Addi tem "10"

            Comment

            • ardhuru
              New Member
              • Dec 2007
              • 4

              #7
              Thanks, the error has gone; but the value still doesnt show up in the combo box.

              I guess I need to understand things more before I return, I don't want to use up more of your time.

              Again, thanks a lot.

              Regards,

              Anand
              Last edited by Killer42; Dec 24 '07, 09:11 PM.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                What version of VB are you using?

                Comment

                • coopdog
                  New Member
                  • Dec 2007
                  • 5

                  #9
                  If you are using vb express 2005 they changed the format. combobox1.items .add "add your string here"

                  If you wish to display as per a text or label. Add the item then use combobox1.text = "The same string as before"

                  Mike
                  Last edited by Killer42; Dec 24 '07, 09:23 PM.

                  Comment

                  Working...