Consulting

Results 1 to 4 of 4

Thread: textbox value

  1. #1

    textbox value

    hi
    i have a text box in a userform that displays data after calculating data from cells in a sheet.
    but after working out the calculation can i set some perimeters for the text box. so it has a ? sign in front of the value, or rounds a decimal number to 2 decimal places?
    thanks ash

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    ash

    No you can't, a textbox has no such parameters to set.

    What you probably want is the Format function.
    [vba]
    x = 10

    Textbox1.Value = Format(x, "Currency")
    [/vba]

  3. #3
    what is the x = 10 for?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub TextBox1_AfterUpdate()
    With Me.TextBox1

    .Value = Format(Replace(Replace(.Value, ",", ""), "?", ""), "?#,##0.00")
    End With
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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