jamorrell
jamorrell

Reputation: 25

VBA Userform, How do I Successfully Change Textbox Number Format Value

I have a UF calculator I'm using to provide a length measurement. I have one textbox returning the result in decimal inches, but I also have a secondary that I would like to create an "easy read" for use with a standard US measuring tape.

The number format works well in a worksheet cell, but not in this textbox. Is there a better way to go about this?

My value is 106.59375; as a worksheet function/format, the result is 106 19/32. With VBA, I'm given 1/07. I've played around with it, and it seems to be rounding value to 107, then applying the format.

UFChordCalc.TBResult.Value = Round(chordLength, 3)
With UFChordCalc.TBER
    .Value = Application.WorksheetFunction.MRound(TBResult, 1 / 32)
    .Value = Format(.Value, "# ##/##")
End With

Upvotes: 0

Views: 203

Answers (1)

IvanSTV
IvanSTV

Reputation: 364

I'd put the value in 2 string variables - first -before the decimal mark, second - after decimal mark in format "1/32" and then stick together with "&"

Upvotes: 1

Related Questions