Test An Integer Value To See When It Is Positive / Negative?
Sep 18, 2009I 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 RepliesI 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 RepliesI 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 RepliesI need to convert a negative integer to a positive one.
View 14 RepliesIs 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 RepliesIs 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 RepliesThe 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]...
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
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]...
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.
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]....
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 Replieshow I could go about doing it. The console application needs to input a positive integer and output its proper divisors.
[Code]...
How do I have a positive number show the "+" sign before the number.
I feel that this should be easy but my searches must be too broad because I get way more info than I want and don't seem to find the easy fix.
i did this much but something doesn't seem right...the question is A Visual Basic program that requests a positive integer as input, and carries out the following steps:If the number is even, divide it by 2.Otherwise, multiply the number by 3, and add 1 to the result. Repeat this process with the resulting number, and continue repeating until the number 1 is reached.After the number 1 is reached, displayed how many iterations were required to reach the number 1. (Hint: a number is even if number Mod 2 = 0.)
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
Dim num, multiply, divide As Double
[Code]...
develop an application which accepts a positive integer value from the user and outputs the sum of all integers between 0 and the given integer.
View 7 RepliesThe console application needs to input a positive integer and output its proper divisors.[code]
View 2 RepliesI 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 RepliesBelow is my code for an employee class and employeetest module. Im not sure why i cant get the test module to return Salary cannot be negative with i put in a number less than zero and not sure how to get monthly salary to convert to yearly and then giving a 10% raise.[code]
View 4 RepliesI 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 RepliesI am using delta plc. i want to send +1 to +30 & -1 to -30 numbers in 4 byte hex format(xxxx) in vb.net.
View 4 RepliesSimilar in concept to Math.Abs() - I'm looking for a function that when given a positive integer will return the same integer. If given a negative, will return zero.
So:
f(3) = 3
f(0) = 0
f(-3) = 0
Yes, this is simple enough to write on my own but I'm wondering if the .NET Math class already has this built in or if the same can be achieved by cleverly chaining a few Math.* calls?
Similar in concept to Math.Abs() - I'm looking for a function that when given a positive integer will return the same integer. If given a negative, will return zero.So:
f(3) = 3
f(0) = 0
f(-3) = 0
Yes, this is simple enough to write on my own but I'm wondering if the .NET Math class already has this built in or if the same can be achieved by cleverly chaining a few Math.* calls?
I have a visual basic .net application. It has a sql server database and a dataset for it. I have created an interface to the database (passing through my dataset) to add, delete, save etc records in a table.
The ID entry has identity specification:Yes and increment seed 1 When I add a record, instead of giving 1,2,3... as id in the textbox it produces -1,-2,-3 (Negative integers)
I have a program that calculates values of a function, say f, with respect to another variable, say L.I have an array of f(L), for L going from 0 to a given integer value, say t-1 in steps of a value i.I need to export the values of this function to an Excel spreadsheet in a given column, and to do this, I would like to re-index the function f, since i is much less than one, and so the following loop I use (see below) won't work:
For L = 0 To t - 1 Step i
Sheet.Cells(L, 1) = L
Sheet.Cells(L + 1, 2) = f(L)
Next L
The first code in the loop will essentially load the values of L itself, at which the function is defined and calculated, and the next line will load the values of the function at each value of L.Since the indexes of the row and columns in an excel spreadsheet only go in steps of 1, I need to convert the indexes of the function, or the indexes to which L is loaded, so that it would be scaled so that the first entry corresponds to L=0, but the next is L=i, but loaded into row number 2, etc.
I just need some syntax that will tell if a variable is an integer or not. I want to do something like this (i know this isn't correct syntax but this is the general idea):[code]
View 19 Repliesso that I can sort Arrays of Structures? What I'm asking is how do I convert a String.Substring(index = 0, length = 1) to a Number that is ASCII integer 0 - 127 ASCII will this module work?
Public Function IsInteger(ByVal strValue1 As String, ByVal strValue2 As String) As Boolean
' A Sort Function
If strValue1 >= strValue2 Then
Return True
[code]....
how do I convert the string to Binary 0 - 127 ASCII code...
How to let textbox1 only enter positive whole numbers and positive decimal numbers
View 4 RepliesI don't understand the error, Argument not specified for parameter 'test' of 'Public Shared Function TestThis(test As String)'.
Partial Public Class Form1
Shared Sub ReceiveCallback(ByVal ar As IAsyncResult)
Form1.Invoke(TestThis, New Object(){"test"}) 'error
[code].....
For the life of me, I cant seem to do this. In the textbox_textchanged method, I want Button to disable in textbox has anything else besides whole positive integers.If text box has positive integers, i want button1 to enable.
View 6 RepliesHow to set in datagridview column to force it only accept positive decimal value??
If negative , then raise dataerror event??