Convert Positive/negative Number?
Dec 19, 2005
Is there a built-in function in .NET (VB) to convert a negative number into a positive, and vice-versa?I usually end up just using:NegNum = PosNu - (PosNum * 2)PosNum = NegNum- (NegNum * 2)
View 6 Replies
ADVERTISEMENT
Apr 15, 2011
I have temp2 value -52340.0 and hslColor.Luminosity is 240.0 When Dim temp1 As Double = (hslColor.Luminosity - temp2). It shoud give -ve number but I am getting always positive number. results should nbe -52100, but I am getting +52100. How to handle this?
View 4 Replies
Jun 22, 2011
I need to convert a negative integer to a positive one.
View 14 Replies
Apr 19, 2011
I'm creating an emulator for a device to simulate wave forms. My challenge is that when I try to convert the output of the following code, I can't convert the Math.Sin's double output into byte values that lend themselves to the byte array format required by an existing graphing control as listed at bottom below. I''m not sure how to handle this when the sin function creates negative values but the byte values will need to be positive and basically 'shifted up' so that anything over 127 is negative. (0 - 255) unsigned. BitConverter.GetBytes has been suggested but THIS is the result of that attempt.
[Code]....
View 2 Replies
Sep 18, 2009
I am looking for a way to test an integer value to see if it is positive or negative so I can perform the required actions.
View 1 Replies
Jan 19, 2009
Is it possible in an datagridview to use different formatting for negative, positive and zerovalues?I want to show positive numbers in black, negative numbers in red, and zero-values hidden.
View 2 Replies
Apr 25, 2012
The problem is simple: I have a form with textboxes, and in one of those textboxes, I want users to enter either a positive or negative 2-digit number. I'm looking for an easy way to enforce this restriction, i.e. without having to parse the number and check whether its absolute value is below 100.
[Code]...
View 2 Replies
Aug 25, 2011
I'm outputting a Double that can be either (+) or negative (-). If the number is a negative the symbol (-) is included automatically, is there a way to do this for positive numbers as well?
The only (horrible) way I can do this is :
If MyNumber <= 0 then
string.Format("{0:0.00}", MyNumber)
Else
string.Format("+{0:0.00}", MyNumber)
End If
View 2 Replies
Feb 28, 2012
I have written a program that generates and prints 10 random integers from -10 to 10, my problem is that I am returning both negative and positive numbers, aligned right with a pad of 2, but the negative is on the right hand side of my number instead of the left. here is my code, all work but I need to align the numbers and have the correct notation of negative.
[Code]...
View 3 Replies
Apr 11, 2010
I want to alter the .visible property of a label based on if a variable is positive or negative (Hiding it for negative values)
But I want to do this for lots of labels so If Statements are too bulky.
I tried this:
Label1.visible = CBool(IntVariable1)
But it turns out CBool returns True for ANY value and False for Zero.I'd assumed it would be True for positive values and False for negatives.How can I do it without if statements?I considered Modulo or SquareRoots to somehow convert a negative number into zero, but didn't want to complicate things with imaginary numbers.
View 2 Replies
Mar 20, 2010
I tried coding for an application that will display the positive integers, negative integers and zero entered in a inputBox. for some reason it keeps crashing down.here is my code. paging all visual basic professionals. [code]
View 6 Replies
Sep 14, 2009
I have this light sensor circuit that will return positive voltage or negative voltage. I want to plug it into the 9-pin D-Sub port on my computer. I already have a male connector. How do I connect the circuit to the D-Sub connector, and how do I read the value and convert it to a Boolean in a program? How do I set up the cables? It only returns one 1 or 0 value. Is it possible, even?
View 17 Replies
Jun 16, 2009
I am using String.Format("{0:C2}", -1234)to format numbers.is always formats the amount to a positive number, while I want it to become $*-*1234
View 4 Replies
Jun 23, 2009
I am calling the function below from an Excel spreadsheet and the conversion from hex to decimal using the VAL function in the "manufacturer" variable below is coming back with a negative value. The VBA edition is 6.5.
Public Function decMEID(ByVal sKey As String) As String
Dim manufacturer As String
Dim serial As String
[code].....
View 3 Replies
Feb 2, 2010
i have a negative number and i want to change it to its positive
eg -14 to 14
View 22 Replies
May 25, 2009
I need to check a value and make sure that it is not a negative number using a try catch statement I keep getting an error saying that I have to use a method.
Try
TotalCurrentBalance < 0
Catch ex As Exception
End Try
I wouldn't put a if statement would I? I am thinking that would defeat the purpose.
View 2 Replies
May 10, 2011
I'm having problem in my datagridview.I'm using vb 2008 and an access database. When I create a new record for my item the No column (primary key and autonumber in access) always shows a negative number.How can I make that a positive number and it should follow the numbering in the datagridview.
View 3 Replies
Nov 10, 2007
I have written a code that when the click the calculation the button a inputbox pop up and you enter in the income and then you enter in the expense. [code]...
View 11 Replies
Jul 11, 2011
I asked a question earlier about comparing numbers using the "And" comparison operator in If Statements and now I have been toying around with getting my head wrapped around bitwise operators. So I have written a very basic code that will allow me to see the conversion of any decimal number in binary format.[code]Notice here that I am using SByte as the paramerter - which should only contain 8 bits right? However, the message box that appears has 16 bits assigned to negative numbers.
View 1 Replies
Dec 7, 2010
How can I insert a negative number into a byte parameter?
Something like this:
Dim b As Byte = -111
View 4 Replies
Jul 11, 2010
My problem is with the following API.
Private Declare Function GetKeyState Lib "user32" (ByVal keyCode As Integer) As Integer In Windows XP, I could simply use the API like this: If GetKeyState(Keys.Left) < 0 Then 'Move Left If the key was pressed, it was a certain number below 0, the number itself alternated each time you pressed the key but it was always below 0.
My problem is that in Windows 7, when you press the Left key, the number isn't the same, in fact the number isn't even negative anymore. This problem tricked me at first into thinking the API didn't even work as when I ran the .exe of course my code did nothing since GetKeyState never returned a number below 0. I tested the value itself though and found that it never goes negative, the number for the key just decreases a little.
The weird thing is, while the .exe from the Debug folder proved my point that the GetKeyState number was different and thus the program didn't work, running the .exe from the Release folder actually worked, the controls were fine and the API returned numbers less than 0 for GetKeyState. But the .exe from the release folder was built with my old XP computer, as soon as I made a new build with my windows 7 computer the API stopped working again.
Why did Windows 7 change the number returned for when the key is down, is there a way to change it back without having to include some large package with my program? Why did the build from my XP computer work at first? Also it was only the one from the release folder, not the debug one, even though they were both from the XP computer.
I tested some more on windows 7 and found that every time I run the program, the number returned by GetKeyState is completely different. When the key is down the number is 1,000,000 units higher than up, but other than that the number is random each program start.
View 19 Replies
Jun 18, 2012
I got a Mysql sql database for my project. The id field is set as auto increment, which seems to function correctly. But on the form in my text field and datagrid i see a negative number, while in the database its a postitive number. I do not really plan to use the id field right now, but when i do it might cause some problems.
Anybody know why it would show as a negative number on the form(textbox/gridview) and as a positive in the actual database?
View 1 Replies
Sep 29, 2009
is there any way to get a numberupdown text to show the value "+" so if the value is a positive number then it adds the plus sign in front of the digits.
example:
2.00 would become +2.00
3.25 would be +3.25
as when its negative its
-2.00
-3.25
It already adds the negative value when its negative of course.
View 2 Replies
Jan 10, 2012
How to let textbox1 only enter positive whole numbers and positive decimal numbers
View 4 Replies
Oct 29, 2010
I want to convert numbers from 0 to 15 like that
[Code]...
Problem is that when we convert 2 to binary number it gives only 10 in binary, but i want to convert 2 to 4 bit binary number 0010.
View 1 Replies
May 3, 2011
im having trouble understanding this question for a homework assignment. I need to write the PSEUDOCODE for the following scenario, but i got no idea about how to convert a hexadecimal number to a decimal number..You are required to input a two digit hexadecimal number eg. 3f (digits can be entered separately) and calculate the equivalent decimal number. (note the decimal number will be between 0 and 255) . output the decimal number
View 1 Replies
Apr 10, 2011
i got hex number from scale weight example:"90 00 00 01 34 = 180 kg" or "90 00 03 03 7c=49670 kg"how to convert hex to number(integer)
View 8 Replies
May 13, 2009
I am supposed to create a program that converts a number into the date that the number represents. its has to list today's date the date the number represents and the difference between that date and today 0 represents December 31st 1899
View 2 Replies
Oct 14, 2010
I am trying to convert a number so that it has commas in it. If the number is 1234 it should be 1,234 or if its 1000000000 it will be 1,000,000,000.
View 1 Replies
Oct 22, 2009
I want Convert a number to string![code]...
View 6 Replies