Results 1 to 6 of 6

Thread: Combo box format

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Posts
    1,384

    Combo box format

    I want the text in a combo box to always appear in the format 00000 i.e. if the number is 1 then I want it to appear as 00001


    I have tried :

    cbo1 = format(cbo1.text, "00000")

    but it doesn't seem to work

    Any suggestions
    Mel

  2. #2
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    I tested this and it worked. Make sure you put that code in the validation or lost focus event.
    -Show me on the doll where the music touched you.

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    This will place the FIRST item in the ComBoBox as Formated TEXT.
    VB Code:
    1. Private Sub Command1_Click()
    2.     Combo1.Text = Format(Combo1.List(0), "000000")
    3. End Sub

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    This works too

    VB Code:
    1. Private Sub Form_Load()
    2.    Combo1.Text = "1"
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.     Combo1.Text = Format(Combo1.Text, "000000")
    7. End Sub

    But, ur not ADDING these Item (If u want to ADD us .AddItem)

  5. #5
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    Use this code

    VB Code:
    1. Dim i As Integer
    2. For i = 0 To Combo1.ListCount
    3. Combo1.List(i) = Format(Combo1.List(i), "00000")
    4. Next
    -Show me on the doll where the music touched you.

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Originally posted by Ambivalentiowa
    For i = 0 To Combo1.ListCount -1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width