+ Reply to Thread
Results 1 to 11 of 11

Formatting textbox

  1. #1
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20

    Question Formatting textbox

    This should be easy but escapes me. How do I format a textbox on a user form so that the text will read as a fraction. I use a slider/ textbox combo. Then the code divides the slider amount by 32. I want the result to read as 7/32" etc.

    Thanks again for being so on top of things and willing to help us neophites out here!
    Last edited by blue9244; 12-18-2008 at 09:36 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Please Login or Register  to view this content.
    If you want to round it to the nearest 1/32, then
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    This code should work for you
    Please Login or Register  to view this content.
    Check out the sample workbook
    http://www.freewebs.com/davesexcel/f...20userform.xls

  4. #4
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20
    Thanks so very much! That ought to do it!

  5. #5
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20
    I think I marked this one as solved a little too soon. All I'm getting in the text box is: ??/?? and no value... If I leave the code just as you depicted it, I get an interger with ??/?? as a suffix. Here is what I have:

    Please Login or Register  to view this content.
    Thanks again. I'm sure I'm just missing something very obvious to you guys!

    BTW, why would you multiply by 32 only to divide by 32 - doesn't that leave you where you started?

  6. #6
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20
    Could someone please tell me where my error is in the above code? I've tried everything I can think of and nothing works. I'm sure your examples were fine - I just must have missed something along the way.

    Please and thanks very much!

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    We don't have your form or workbook, so debugging is up to you. When you step through the ScrollBar16_Change() code, what's the value of ScrollBar16?

    why would you multiply by 32 only to divide by 32 - doesn't that leave you where you started?
    If you mutiply by N, round to a whole number, and divide by N, the result is rounded to the nearest multiple of 1/N.

  8. #8
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20

    Smile

    I didn't answer quickly because I was attempting to think this through myself but I'm still at a loss. The value of the ScrollBar changes as the user slides the scroll bar. At one point I had it at 108 and stepped through the procedure dividing by 32, I obtained the value I wanted - i.e. 3.375. The text box returns the value as 3.375 correctly. I want it to read 3 3/8 in this case. When I apply the formatting, I get either a type mis-match or the result in the text box as 108 ??/?? depending on where I've tried to apply the formatting.

    Here's the code to obtain 3.375 (or any other number selected by the scroll bar).

    Please Login or Register  to view this content.
    Where FingerOpen1 is Textbox1. Does this help at all?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Huh; who knew Format wouldn't do fractions?

    Change Format to WorksheetFunction.Text

  10. #10
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    I've got a funny feeling that FORMAT doesn't like the fraction component.

    try something like

    Please Login or Register  to view this content.
    EDIT: Darn - shg you beat me to it...

    rylo

  11. #11
    Registered User
    Join Date
    10-23-2008
    Location
    Long Beach, WA, USA
    Posts
    20
    That did it!!!! Thanks so very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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