Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Posts
    67

    Unanswered: Formatting ListBox values

    I am using the below code to populate a three-column ListBox. I am trying to get the ListBox to display the values in the formats shown. The ListBox displays the values but ignores the formats. Does anyone know how I can get the ListBox to display the values in the desired formats?

    Thanks much for any help.

    Jim

    Dim VarDol as Currency
    Dim RelVal as Double
    Dim Xnum as Long

    VarDol = Format(rs2("Var"), "$0.00;($0.00)")
    RelVal = Format(rs2("Rel"), "0.000;(0.000)")
    Xnum = Format(rs2("X"), "0,000;(0,000)")

    lstSaved.AddItem VarDol & ";" & RelVal & ";" Xnum

  2. #2
    Join Date
    Jan 2004
    Posts
    26
    Try this:

    Dim VarDol as String
    Dim RelVal as String
    Dim Xnum as String

    VarDol = Format(rs2("Var"), "$0.00;($0.00)")
    RelVal = Format(rs2("Rel"), "0.000;(0.000)")
    Xnum = Format(rs2("X"), "0,000;(0,000)")

    lstSaved.AddItem VarDol & ";" & RelVal & ";" Xnum

  3. #3
    Join Date
    Feb 2004
    Posts
    67
    Originally posted by Balinor
    Try this:

    Dim VarDol as String
    Dim RelVal as String
    Dim Xnum as String

    VarDol = Format(rs2("Var"), "$0.00;($0.00)")
    RelVal = Format(rs2("Rel"), "0.000;(0.000)")
    Xnum = Format(rs2("X"), "0,000;(0,000)")

    lstSaved.AddItem VarDol & ";" & RelVal & ";" Xnum

    Defining the variables as String seemed to create random formats. Some items were shown as currency while others were shown as decimals (even numbers within the same column). Changing just one variable as String even impacted how the other variables were formatted in the ListBox. I guess I just don't understand what the ListBox is doing.

    Any other suggestions?

    Thank you.

    Jim

  4. #4
    Join Date
    Jan 2004
    Posts
    26
    Just noticed. there should be another & inbetween ";" and Xnum, on this line:
    lstSaved.AddItem VarDol & ";" & RelVal & ";" Xnum

    Not sure if that is causing your problem or not though.

    Scott

  5. #5
    Join Date
    Feb 2004
    Posts
    67
    Originally posted by Balinor
    Just noticed. there should be another & inbetween ";" and Xnum, on this line:
    lstSaved.AddItem VarDol & ";" & RelVal & ";" Xnum

    Not sure if that is causing your problem or not though.

    Scott

    Good Catch but no that is not what is causing my problem. I actually have eight columns. I just truncated above statement and neglected to add the "&" before Xnum.

    Thanks for the response.

  6. #6
    Join Date
    Jan 2004
    Posts
    26
    Not sure if this will work, but try adding them individually, like so:

    lstSaved.AddItem VarDol
    lstSaved.AddItem RelVal
    lstSaved.AddItem Xnum

  7. #7
    Join Date
    Feb 2004
    Posts
    67
    Originally posted by Balinor
    Not sure if this will work, but try adding them individually, like so:

    lstSaved.AddItem VarDol
    lstSaved.AddItem RelVal
    lstSaved.AddItem Xnum


    This added all items to the first column of the ListBox.

    Thanks for another try.

Posting Permissions

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