+ Reply to Thread
Results 1 to 6 of 6

TextBox Formatting on a Form

  1. #1
    Registered User
    Join Date
    04-18-2008
    Location
    Ipswich, England
    MS-Off Ver
    Office 2007, 2003, 2000, XP
    Posts
    17

    TextBox Formatting on a Form

    Ok. This should be easy.

    I have a UserForm that has TextBox's for inputting a price (TextBox1) and an optional discount (TextBox2). The third TextBox (TextBox3) is then a simple calculation TextBox 1 - TextBox 2. So far, so good. The inputs are stored on the worksheet as they need to be recorded. ColA amount Col B discount ColC is the adjusted amount.

    The TextBox s need to be formatted as currency and so I have used
    Please Login or Register  to view this content.

    and similar for TextBox2

    This works for the non-calculated cells but not for the calculated ones. I have tried every combination formats but cannot get TextBox3 to format automatically and stay formatted.

    I must be missing something, but what?
    Last edited by royUK; 07-07-2008 at 01:21 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    Quote Originally Posted by UKSteveH
    Ok. This should be easy.

    I have a UserForm that has TextBox's for inputting a price (TextBox1) and an optional discount (TextBox2). The third TextBox (TextBox3) is then a simple calculation TextBox 1 - TextBox 2. So far, so good. The inputs are stored on the worksheet as they need to be recorded. ColA amount Col B discount ColC is the adjusted amount.

    The TextBox s need to be formatted as currency and so I have used

    Private Sub TextBox1_AfterUpdate()
    Range("C1") = Range("A1") - Range("B1")
    TextBox1 = Format$(TextBox1, "£ #.00")
    TextBox3 = Format$(TextBox3, "£ #.00")
    End Sub


    This works for the non-calculated cells but not for the calculated ones. I have tried every combination formats but cannot get TextBox3 to format automatically and stay formatted.

    I must be missing something, but what?
    A textbox will not stay formatted, you need some kind of event for it to format, such as textbox exit or the exit of another textbox or whatever, just as long as you understand, it does not remain formatted, until something else happens to format it......

  3. #3
    Registered User
    Join Date
    04-18-2008
    Location
    Ipswich, England
    MS-Off Ver
    Office 2007, 2003, 2000, XP
    Posts
    17
    Yes I realise that.

    I have tried various methods textbox_change, textbox_afterupdate and others. The only method that worked consistantly was when the calculated cell was selected, which defeats the purpose of a calculated field.

    However, I have resolved it (I think) by formatting the textbox on the UserForm_Initialize - for some reason it retains the formatting, using the same command - I don't get it - but it is working....

    Steve

  4. #4
    Registered User
    Join Date
    11-28-2005
    Location
    Saint Louis, Missouri USA
    MS-Off Ver
    2016
    Posts
    69
    Did a seach.. bringing this thread back to life. This half-way answered my question.

    I have a userform that enters a currency textbox into a cell on a spreadsheet. It has been just using a text format, which was causing me grief. I used this format$ command to format the textbox before the data was copied to the particular cell in my spreadsheet.

    BUT, I can not find any help on Format$. I wish to use an accounting format and/or something with no decimal places.

    AND, what's the best way to format the textbox on the form so the user gets the dollar sign, at least, when they fill in the amount?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    UKSteveH

    Welcome to the forum. To use this Forum to get your FREE help, we expect you
    to read 7 follow our simple rules.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by evanzo
    Did a seach.. bringing this thread back to life. This half-way answered my question.

    I have a userform that enters a currency textbox into a cell on a spreadsheet. It has been just using a text format, which was causing me grief. I used this format$ command to format the textbox before the data was copied to the particular cell in my spreadsheet.

    BUT, I can not find any help on Format$. I wish to use an accounting format and/or something with no decimal places.

    AND, what's the best way to format the textbox on the form so the user gets the dollar sign, at least, when they fill in the amount?
    With 32 posts you should have read the Forum Rules by now & know not to ask your question in another user's post. Start your own question & reference this one with a link.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1