VS 2010 Check If A Number Contains Decimals?
May 29, 2010VS 2010 check if a number contains decimals?
View 6 RepliesVS 2010 check if a number contains decimals?
View 6 RepliesDim y as integer
dim x as double = 125 / 60
y = Convert.ToInt32(x) 'removes decimals
That method works, it removes all the numbers after the decimal.
But, how to check if the double contains a decimal and if it has it, remove all the numbers after it?
I have tested all the possible solutions i can think of, but I always run into a lot of errors
I'm trying to check for the number of decimals in a textbox, but I'm not very successful so far:[code]How can I correct my code to make it work? Or any other/better solutions?
View 2 Replieshow do you detect how many decimals a decimal number has
View 10 RepliesI need to check whether a certain number is a member of the array. Is this a good way?[code]
View 1 RepliesIs this the proper way to bring up an error if the user inputs more than 2 decimals. 'Not decCost = [0-9]*.[0-9]{0,2}
[Code]...
I am writing a Do Until Loop to check if the number entered in a textbox is between 1 and 12 in Visual Basic 2010.
View 4 RepliesI want the program to check the number of items in a list box, then send use that number to form a FOR loop and send each to the serial port individually. It actually sends everything, but the program always crashes after the last one saying that the sdprintcount variable is an invalid number for the index. I don't get it as this happens no matter how many items are in the list, and it always crashes on the last one. It sends it, but then it says the index number is invalid.
*********************************
Dim sdmods As Integer
Dim sdmodsp As String
sdmods = sandwichmodlist.Items.Count
[code]....
Tabpages: Using a button, how do I go from tabpage1 to tabpage2? I have it kind of sorted, only not: Button click tabpage1 send to back() or hide() tabpage2 show() The problem with this, is it does not actually turn the page, and the tabpage1 tab still shows at the top. Decimals: Epically basic, I guess. I have calculations that does, for example: 10/6 = 1.666666666667 How do I get it to say 1.667 only?
And Lastly, Graphs: I have a line graph. I have fixed series as a envelope for the variable series to sit in. Again, epically basic - How do I make a series that draws a line for a variable?
I am trying to filter a dataset using a number different inputs, selected by a number of check boxes. I have all the text base rowfilters working, but I can not make the date filter work unless I hard code the datetime into the code. The database is MS Access and I am using VB2008 to show the data. I would like to be able to use a DateTimePicker to set the filter date (without the time part) Also I would need to remove the time section of the datEnterDate. I cannot change the structure of the database fields. Also the datEnterDate is MM/dd/yyyy, because I'm in England I would like to use the format of dd/MM/yyyy if possible
[Code]...
I am trying to make a basic ATM system, iv got all the interface done and I have made the link to my SQL database etc. the part i'm stuck on is how I can run a check to see if a bank card number matches up to the users PIN number. To simulate the user putting a card into the machine I've used a combo box, and that lists all the cards, that haven't been flagged as confiscated (there's a column in my ATMCards table that I can set to true or false) then after the user has selected a relevant card there's another text box where they can enter in their PIN number.
Now what I want to do is, if they chose the card number 1234567890123456 in the combo box and they enter in the PIN 1234 into the text box, then, after clicking the check PIN Button if the pin is correct they need to be taken to another from where they can check their balance etc., and if its wrong they got three attempts after which point i want to flag that card as confiscated.
I got 2 LABELS and ONE BUTTON... when i press the button, it fills both labels with a random number from 1 - 6.ild like to do it like this... you press the button then a little prograss bar starts running for 3 or 4 seconds... and THEN after it reached the bars max i want it to show the numbers in the Labels...
the second thing is...i want to make 2 checkboxes next to the labels... if you mark the first checkbox, next to the first label... and the outcome is that the number of the first label is BIGGER then the other one.. you should get some kind of a msgbox.. i know how to make a msg box... but i dont know the code for vb to check if label1 is > or < than label2....
Is there a way to check if a number in a TextBox is an even or uneven number?
View 8 RepliesPart of my assignment is to check if input to Group Number and Number of Units are correct input by making error handling exceptions...
I have to check the following:
a) group number is neither 501 nor 062
b) number of units are NOT numbers
c) number of units is NOT a positive number
So my first question is, am I checking correctly? 2nd question is, How do I make sure my Exceptions will pertain to their correct respective things (a, b, and c.. above)?
[Code]...
Is there an easy way to check whether a number is a prime number? I've tried doing this:[code] url...
View 3 RepliesIs there an easy way to check whether a number is a prime number? I've tried doing this:
Code:
Public Function IsPrime(ByVal Input As Integer)
Dim NewInput As Integer
[code].....
I was trying to get this work, but couldn't find a way to work this out. I'm new to vb.net. In a text box, the user enters a number for example a 9 digit number. I want the user enter to enter a 9 digit number that is starting from 8. if the very first number of that set is not starting with 8 then give a error msg to the user to enter a number starting from 8.
View 1 RepliesI'm reading data in from a comma-separated text file and storing the data in an array for later use. Some of the values are to remain as strings, and I need to convert some to integers, for which I was trying to use, for example, integer.parse(ar(0)).
My problem is that the string values are randomly distributed through the text file, so I need to be able to test whether the string can be converted at all before doing the conversion.
I have class representing a unit of measure with a Decimal as the numeric. Just to simplify things for this example, let's say I'm representing centimeters. I'd like to implement a ToString() method for this class. The thing is, if the numeric value is a whole number I'd like to just display the decimal as an integer. Otherwise, I'd like to keep it as a decimal. So, for example, 10.5D centimeters would display as "10.5cm", but 7.0D centimeters should display as "7cm". I'd like this to be fast and simple to read. I have a working solution, but it seems like there should be a better way.Here's a contrived example showing my first crack at it:
Public Property Units As String = "cm"
Public Property NumericValue As Decimal = 10.5D
Public Overrides Function ToString()
[code].....
How do you check to see if a string is a numberic value?
View 7 Repliesim using a datagridview, and it is connected to ms access. every time i have an input same in the column where primary key is I already got an error. can you guys how to show a messagebox if the Customer Contact number is already in use? here is my code.
[Code]...
I can't seem to figure out how to make a function that check if x is a multiple of y. For example, 64 is a multiple of 8.Here's what I have, it's simple but I'm stuck:
Function IsMultiple(ByVal Number As Integer, ByVal Multiple As Integer) As Boolean
If Number / Multiple = 0 Then
IsMultiple = True
End If
End Function
Line2, if the number is a multiple it would return a number without decimal, but I dunno how to check if it is or not.
I am using vb express edition 2008. I need to check if an infinity (or NaN) number does exists but I don't know what my mistake is.
Dim Slop1 As Double
Slop1 = (20 - 10) / 0
If Double.IsNaN(Slop1) Then
MsgBox("Check the Coordinates")
End If
whats the diference between the 'IsNaN' and 'IsInfinity' is?
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.
I was wondering what the fastest way is to check for divisibility in VB.NET.I tried the following two functions, but I feel as if there are more efficient techniques.
Function isDivisible(x As Integer, d As Integer) As Boolean
Return Math.floor(x / d) = x / d
End Function
Another one I came up with:
Function isDivisible(x As Integer, d As Integer) As Boolean
Dim v = x / d
Dim w As Integer = v
Return v = w
End Function
I've just begun using VB2008 Express. As practice, I'm trying to create a simple program that allows users to practice their basic arithmetic skills. I've just run into one hiccup.
I have a procedure that generates random numbers for the program to spit out as text that the user will then do arithmetic on. I'm trying to create a loop that checks, in the case that a radio button selecting division practice, that the potential quotient [code]...
i want a user to entera number and then check if the number entered fall between the minmum number specified and the and maximum number specified inclusive.i have this code but itis not working for me as i want.that is if the entered number is not within the min. and max. inclusive then it should promt the user.
if number>=minnuber and number <=maxinumber then
exit sub
else
messagebod.show("number is out of range.number must be between the minimum and the maximum number")
end if
How do you check if the division of two integers is a whole number, just answer with code, no links?
View 6 RepliesI want to check if the value in the text box is EVEN NUMBER.else throw an error mssg.
View 3 RepliesI have a listbox, textbox, and a button. every time I push the button, an item from the listbox is put into the textbox. when the button is pushed again, it grabs the next item in order and puts it into the textbox. so on and so on until it gets to the last item. once I get to the last item it keeps repeating the last item over and over again. SO what I was wondering is how do I get a messagebox or some sort of checker to tell me when it has moved the last item from my listbox to the textbox?? PS textbox2.text=0 and every time the button is pushed another number is added to the value of textbox2.text. so basically if I could figure out how to grab the value of lines at any given time in listbox I could call a msgbox up!! here is the code I am currently using[code]...
View 3 Replies