Truncating whole numbers to be 4 digits

M

mpfohl

I have a key that the user enters and then I want to manipulate. The
user enters a 4 digit number (X), and I run my equation on it (let's
say, X*2) and return back a 4 digit number. What the number is
doesn't really matter, as long as it is consistant each time the user
enters the same number, and as long as it is exactly 4 digits long.

So basically, I need a way to truncate integers. how do i say take 4
digits from (X*2) ?

Thanks
 
A

Arvin Meyer [MVP]

It would depend upon which 4 digits you wanted. You can get the left 4:

Left(x*2,4)

or the right 4:

Right(x*2,4)

If you need them to be a number instead of a string, just convert it back:

CInt(Right(x*2,4))
 

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