Click here to Skip to main content
12,698,204 members (21,994 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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 20: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 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 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.
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  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 27 Jun 2013
Copyright © CodeProject, 1999-2017
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