Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
hi
in my project i am displaying cheque number randomly
like random.next(100000,999999) it will give some value randomly like 234567
in that i should select last two digits and set cheque number range from 1 to 10
like (234568 to 234578) can any one help me for how to do this


thanks in advance
pallavi
Posted
Comments
Toli Cuturicu 14-Apr-11 4:40am    
Not clear.

I am not able to understand complete thing what you have written. Although this is how you can get the last two digits from a number:

int lastTwoDigits = number % 100;
 
Share this answer
 
Comments
Pong D. Panda 14-Apr-11 3:48am    
right on the spot!
Tarun.K.S 14-Apr-11 3:57am    
Good answer!
You can simply do modulo 100 to get the last 2 Digits.

int a = 123456789
int b = a % 100
Console.WriteLine("b: ",b);


Output :
b = 89
 
Share this answer
 
v2
Comments
pallaviAshwath 14-Apr-11 3:56am    
thanks for your solution
in asp.net i have textbox for cheque No=12345
but it should display specified range i have specified from 1 to 10
Cheque no range from =12346
cheque no range to=12356
how to do this
Legor 14-Apr-11 4:08am    
Sorry but i dont seem to get your questions here. Would you like to display whole numbers in a specified range or would you like to display numbers which only contain digits of a specified range and what does this have to do with your questions how to get the last 2 digits ?
Tarun.K.S 14-Apr-11 3:57am    
Good answer!
Legor 14-Apr-11 4:09am    
Tahnks, and thanks for the edit ;)
I think you mean that you want to to change your last 2 numbers for example if they are 12 you want them to be 22 right?

I will assume the answer is right anyway :-D

so here it is

all you have to do is to add 1 to your number :-)

123456 + 1 = 123457 and here is the from

and add 11 to it too

123456 + 11 = 123467 and here is to

and here is your range

I hope I helped
:-)
 
Share this answer
 
v2
Comments
pallaviAshwath 14-Apr-11 5:18am    
thanks i got it
Legor 14-Apr-11 7:16am    
So is that what you were looking for ?
a1mimo 14-Apr-11 7:26am    
I think this was it or that what I understood from his comment on your answer :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900