PDA

View Full Version : Solved: Convert Fractions To Decimals in UserForm



sooty8
11-08-2011, 04:47 AM
Hi & Good Morning

I have a very basic UserForm which I have attached - I use to keep my racing account updated the attached is obviously a test. The combobox is used for fractions and I need it to automatically update the textbox (Odds2) after selecting the fraction in the combobox - Odds2 can then be used to workout the calculation on the sheet.

Any help much appreciated

Regards

Sooty8

mdmackillop
11-08-2011, 05:19 AM
Private Sub TbOdds_Change()
Dim Dec As Variant
TbStake.Value = Format(Val(Trim(TbStake.Value)), "###0.00")
Dec = Split(TbOdds, "/")
Dec = Dec(0) / Dec(1)
TbOdds2 = Format(Dec, "0.000")
TbReturn.Value = Format(Val(Trim(TbOdds2.Value * TbStake.Value + TbStake.Value)), "###0.00")
End Sub

mikerickson
11-08-2011, 07:27 AM
I'm not sure what goes where, but the fact that Evaluate("3/4") = 0.75 might be useful to you.

sooty8
11-08-2011, 08:39 AM
Hi Md

Thanks for the help just had to alter the combobox from Change to Click the line Dec = Dec(0) / Dec(1) was displaying an error until I changed it as above now works OK - sorry about the delay in answering my internet has been up down more times than a fiddlers elbow today - I detest Explorer9 might even go back to Explorer8 at least that always worked OK. Again many thanks
Regards Sooty8