View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default VBA to identify last digit in integer

On Fri, 26 May 2006 21:07:59 -0500, brucemc
wrote:


I need to identify the last digit in a test integer.

I presently am about to convert the integer to a string, use
Right(TestInteger,1) to extract the last character, then convert that
character back to a value. Seems to me I, once again, am probably
missing some other painfully obvious and easier means.

Any ideas?


TestInteger Mod 10


This seems to work in VBA:

==========================
Sub LastDigit()
Const Num As Long = 79368412

Debug.Print "Last Digit in " & Num & " is " & _
Num Mod 10
End Sub

===========================


--ron