TextBox Formatting

G

grahammal

How do I format a UserForm TextBox to round decimal numbers to the
nearest whole number.
ie
1.0, 1.1, 1.2, 1.3, 1.4 should all round down to 1.
1.5, 1.6, 1.7, 1.8, 1.9 should all round up to 2.
I can get it to display the Interger but this always rounds down.
 
D

Dave Peterson

dim myVal as double
myval = 1.4
me.textbox1.value = round(myval,0)

if you're using xl97:
me.textbox1.value = application.round(myval,0)
 
G

grahammal

Your resolve is fine thankyou but I should have made my query a littl
clearer.
The decimal to resolve is'nt just between 1 & 2 it could be anything.
ie 2.7, 7.1, 11.6, 5.3 etc.
Can you work your magic once more
 
D

Dave Peterson

The part that does the work is this line:

me.textbox1.value = round(myval,0)

I guess the next question is where do you get the value you want to round?

I just created myVal to have some test data. You'd use whatever variable holds
that number.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top