Results 1 to 9 of 9

Thread: [RESOLVED] add item to combo box and related price

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: add item to combo box and related price

    The ItemData property can only store Integers. One option is to multiply the value by 100 when it is stored and obviously divide by 100 when the value is retrieved.

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim sngValue As Single
        
        sngValue = 1.98
        Combo1.AddItem "A new service"
        Combo1.ItemData(0) = sngValue * 100
    
        Combo1.ListIndex = 0
    End Sub
    
    Private Sub Combo1_Click()
        Label1.Caption = FormatCurrency(Combo1.ItemData(0) / 100, 2)
    End Sub

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: add item to combo box and related price

    Quote Originally Posted by brucevde
    The ItemData property can only store Integers. One option is to multiply the value by 100 when it is stored and obviously divide by 100 when the value is retrieved.

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Dim sngValue As Single
        
        sngValue = 1.98
        Combo1.AddItem "A new service"
        Combo1.ItemData(0) = sngValue * 100
    
        Combo1.ListIndex = 0
    End Sub
    
    Private Sub Combo1_Click()
        Label1.Caption = FormatCurrency(Combo1.ItemData(0) / 100, 2)
    End Sub
    Nice idea.

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