Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hello guys,
 
Could you help me ,
I'm having some problem in the negative sign(-) in the integer.
all i want is to remove the negative sign in the integer
but i just dont know ....
 
here's my code...

If RS1_1.Checked = True Then
Temp_PC = Temp_PC + 1
Else
Temp_PC = Temp_PC - 1
TXTSPC.Text = Temp_PC
End If

 

please help..
Posted 13-Jul-10 19:27pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you want to make a number be positive, no matter how it starts, use Math.Abs. If you want to remove the sign from a string, you can use math.Abs, or String.Replace.
 
You should consider buying a basic VB.NET book to help you with these sort of questions.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi, here is a solution for your question.
 
if arrval is a negative value
if (arrval < 0)
     {
           arrval = arrval * (-1);
       }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Use the Math.Abs() method.
 
EDIT -----------
 
Sorry, didn't know Christian had already suggested it. If the OP had marked it as answered, I wouldn't have bothered with a response.
  Permalink  
v3
Comments
aspdotnetdev at 14-Jul-10 14:34pm
   
FYI, you can just delete your answer if you like. I could too, but I figured I'd leave the decision up to you.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 338
1 _Amy 290
2 Maciej Los 260
3 Manfred R. Bihy 200
4 OriginalGriff 195
0 OriginalGriff 7,445
1 Sergey Alexandrovich Kryukov 6,347
2 Maciej Los 3,799
3 Peter Leow 3,558
4 CHill60 2,702


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 27 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100