Detect the number of decimal places in a userform text box?

lgjmac

New Member
Joined
May 6, 2013
Messages
10
I have created a userform and it has several textboxes where the user inputs numbers (these will be financial data prices). In one text box the user enters the Price of the asset.

This price can vary in format: it may be £2.27, $123.56 or £64.5902.

I want the userform to work out how many decimal places are in the inputted data and then display the smallest change in a textbox (which can then be altered if necessary).

So, if the Price data is £53.68 then the second box would show £0.01. If the Price data was $123.5392 then the second box would show $0.0001.

Please help!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Something like this maybe...
Code:
If TextBox1.Text Like "*.*" Then
  SmallestChange = "$0." & String(Len(TextBox1.Text) - _
                   InStr(TextBox1.Text, ".") - 1, "0") & 1
Else
  SmallestChange = "$0"
End If
 
Upvote 0

Forum statistics

Threads
1,215,195
Messages
6,123,572
Members
449,108
Latest member
rache47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top