Click here to Skip to main content
15,887,875 members
Home / Discussions / C#
   

C#

 
QuestionCompare listview item Pin
andredani9-Sep-07 3:22
andredani9-Sep-07 3:22 
AnswerRe: Compare listview item Pin
Mark F.9-Sep-07 11:18
Mark F.9-Sep-07 11:18 
GeneralRe: Compare listview item Pin
andredani10-Sep-07 0:37
andredani10-Sep-07 0:37 
GeneralRe: Compare listview item Pin
Mark F.10-Sep-07 3:40
Mark F.10-Sep-07 3:40 
GeneralRe: Compare listview item Pin
andredani10-Sep-07 4:17
andredani10-Sep-07 4:17 
QuestionProblem with LDF files ( database log file ) Pin
Developer6119-Sep-07 2:20
Developer6119-Sep-07 2:20 
QuestionHow to display # using / and % Pin
programming1019-Sep-07 2:16
programming1019-Sep-07 2:16 
AnswerRe: How to display # using / and % Pin
Christian Graus9-Sep-07 2:33
protectorChristian Graus9-Sep-07 2:33 
Hi - welcome to Code Project.

digit2 = value1 % 10000

will give you the remainder when dividing by 10000. In essence, this means it will give you the last four digits. To get just the one digit, you'd also have to strip to the right, so something like this should work

Math.Floor((value1 % 10000)/1000)

The mod (%) strips values to the left, then the divide strips to the right. Finally, Math.Floor stops a result such as 3.6 from rounding up.

The other approach is to do this:

string number = value1.ToString();

digit1 = int.Parse(number[0]);
digit2 = int.Parse(number[1]);

etc

You don't need to use int.TryParse or char.IsDigit, as you know the values are all numbers. You DO have to make sure your number is 5 digits long, I'd be inclined to store the values in a list or an array, then you can write code that works with any length number.


Christian Graus - Microsoft MVP - C++

"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

AnswerRe: How to display # using / and % [modified] Pin
Julian Nicholls9-Sep-07 2:48
Julian Nicholls9-Sep-07 2:48 
QuestionCreating textboxes Pin
garga19-Sep-07 0:40
garga19-Sep-07 0:40 
AnswerRe: Creating textboxes Pin
Giorgi Dalakishvili9-Sep-07 1:07
mentorGiorgi Dalakishvili9-Sep-07 1:07 
Questiondrag and drop in datagridview??????? Pin
San@Coding9-Sep-07 0:14
San@Coding9-Sep-07 0:14 
Questionhow can send a Unicode message with "at command" and gsm ? Pin
B.A8-Sep-07 21:42
B.A8-Sep-07 21:42 
AnswerRe: how can send a Unicode message with "at command" and gsm ? Pin
Giorgi Dalakishvili8-Sep-07 23:34
mentorGiorgi Dalakishvili8-Sep-07 23:34 
GeneralRe: how can send a Unicode message with "at command" and gsm ? Pin
B.A9-Sep-07 19:18
B.A9-Sep-07 19:18 
GeneralRe: how can send a Unicode message with "at command" and gsm ? Pin
Giorgi Dalakishvili9-Sep-07 20:36
mentorGiorgi Dalakishvili9-Sep-07 20:36 
QuestionKey Presses Pin
ahojed8-Sep-07 21:00
ahojed8-Sep-07 21:00 
AnswerRe: Key Presses Pin
Ermak868-Sep-07 22:50
Ermak868-Sep-07 22:50 
AnswerRe: Key Presses Pin
Giorgi Dalakishvili8-Sep-07 23:23
mentorGiorgi Dalakishvili8-Sep-07 23:23 
GeneralRe: Key Presses Pin
ahojed9-Sep-07 4:14
ahojed9-Sep-07 4:14 
GeneralRe: Key Presses Pin
Giorgi Dalakishvili9-Sep-07 4:40
mentorGiorgi Dalakishvili9-Sep-07 4:40 
Questionsocket programing Pin
ali_reza_zareian8-Sep-07 19:19
ali_reza_zareian8-Sep-07 19:19 
AnswerRe: socket programing Pin
Ermak868-Sep-07 22:55
Ermak868-Sep-07 22:55 
Questionsocket programing Pin
ali_reza_zareian8-Sep-07 19:19
ali_reza_zareian8-Sep-07 19:19 
AnswerRe: socket programing Pin
Vasudevan Deepak Kumar8-Sep-07 23:56
Vasudevan Deepak Kumar8-Sep-07 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.