Round A Number But It Is Not Giving Correct Answer?
Jan 14, 2011
In vb.net i am going to round a number but it is not Giving me correct answer. i.e.
Round (1.5,0) = 2
Round (2.5,0) = 2 which is wrong. the answer should be 3.
(When i use the Round formula in Excel it gives me the correct answer)
View 3 Replies
ADVERTISEMENT
Oct 16, 2009
I've got this code to get the decimal and groupseparator settings on a computer:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim NumFormat As New System.Globalization.NumberFormatInfo
[Code]....
The problem is that on my computer NumberDecimalSeparator should return "," and NumberGroupSeparator should return ".", but it's just the other way around when I try to get both separators from my system. What could be going wrong, and even more important, how to get the right strings? I did check my locale setting to make sure I'm not crazy and I also didn't switch the textboxes.
View 2 Replies
May 7, 2009
I'm currently creating a maths game for primary school children and have questions based on addition, subtraction, division and multiplication.I tried it out yesterday and if I type in the correct answer, I get told it's wrong, but if I type in the in the number I'm dividing by, as the answer it comes up as correct. How do I change this so that the correct answer is actually the correct answer?
View 2 Replies
Apr 18, 2009
I have created a basic query generator which allows a user to select the Select, WHERE and criteria attributes using a number of checkboxes.However i have got stuck. In the results form i have the following code
Private Sub DisplayRecord()
RichTextBox1.Text = ds.Tables("newResults").Rows(intCurrentRecord).Item(0)
RichTextBox2.Text = ds.Tables("newResults").Rows(intCurrentRecord).Item(1)
RichTextBox3.Text = ds.Tables("newResults").Rows(intCurrentRecord).Item(2)
[code]....
The program keeps on crashing if the user does not select the corresponding amount of display records from above for the amount of attributes they want for the SELECT part of the query in the intreface in form 1.
How would i go about making something where the number of SELECT attributes selected which are listed in a string create the correct number of textbox fields in the results form (form2)
View 1 Replies
Oct 29, 2011
'Declaringvariables
Dim sAnswer As String
Dim sCheck As String
[code].....
View 6 Replies
Apr 6, 2012
I want to add a counter for my program that basically counts the times I answered correctly and incorrectly. When a user adds or subtracts correctly the correct label shows 1 and when a user correctly answers again the correct label should show 2. It just adds and adds until the program is running. Same goes for the incorrect label.
View 1 Replies
Jan 26, 2011
I started to create the MathQuiz and it is working good as per the provide codes. I was also able to add 'Percentage Correct Answers' and some other details.I have added a new form with some buttons and that is working as well, just simple stuff and all good fun playing with it.
But here is my challenge:When 1 or more answers are incorrect the program is opening a new form (similar to the main form) and it shows the equations again. I did that with "Correcting.lblLADD.Text = addend1", etc. in then main form. In the form 'Correcting' = Form3.Designer.vb I have tried to get the Text into a Number but nothing works for me. Also Tried to make addend1 in Form1 Public but the value does not appear in Form3. Form3 has also a Private addend1 as Integer.Even if I give addend1 in Form3 a value Form3 does not calculate.Maybe it does but I can get it to work. I have tried to get a MessageBox to show up when the answer in Form3 is correct but the MessageBox does not work either.
View 10 Replies
Mar 20, 2012
I'm trying this in two application; a console application and a web application.
In the console app when I try Double.Parse("0.5") it gives 0.5 or Double.Parse(".5") gives 0.5
But in the web application Double.Parse("0.5") gives 5.0 and Double.Parse(".5") gives exception
Input string was not in a correct format.
how can resolve the issue in web app?
View 1 Replies
Jul 23, 2010
I want round up given numbers in c#
Ex:
round(25)=50
round(250) = 500
round(725) = 1000
round(1200) = 1500
round(7125) = 7500
round(8550) = 9000
View 4 Replies
Dec 15, 2011
I can't round up the decimal number using VB.net
i'm using Cint(12.5) this must be 13 but it is not so i try Round(12.5) but still not roundup what do i do?
View 5 Replies
Aug 4, 2009
I have a vb application that need to round a number down e.g. 2.556 would become 2.55 and not 2.26
I can do this using a function to strip off the characters more that 2 right from the decimal point using this[code]\...
View 3 Replies
Jul 29, 2011
how can i always round a double up?
2.3 = 3
2.5 = 3
2.8 = 3
i always want to round up to the nearest whole number
View 3 Replies
Jun 10, 2012
How could i round an integer number based on the last digit of the number?
For example:
Dim x As Integer = 12
Dim y As Integer = 139
Dim z As Integer = 2322
[Code].......
View 3 Replies
Jan 5, 2011
I need to round like this:
12 -> 10
152 -> 200
1538 -> 2000
25000 -> 30000
etc.
Twisting my head, but can't see how to make this. Must work for any n number of digits. Anyone got an elegant method for it?
View 6 Replies
May 26, 2010
I am trying to round a number but I keep getting an Infinity number. How do I round this.
4000 / 7135 * 100 Here's the code I've tried.
Round(readVals(0) / Scaling1 * 100 + ActualValueLow1, 2)
FormatNumber(readVals(0) / Scaling1 * 100 + ActualValueLow1, 2)
View 12 Replies
Nov 21, 2011
Decimal number in my textbox I need to round to the nearest even number. Is there any idea how to do it?
View 21 Replies
Apr 16, 2009
I'm creating a number guessing game. [Code] Textbox1.text refers to the answer input by player. There are two labels for displaying the range of the answer within. Label1 and Label2 refer to the lower limit and higher limit respectively. If the input value is smaller than the answer, the label1 will show the number that input into texybox1. If the input value is larger than the answer, then vice-versa. However, the program doesn't work as my expectation. Once I input the answer, the MsgBox doesn't appear. When the input value is smaller than the answer, the label1 doesn't show the input value.
View 15 Replies
Jan 8, 2009
is it possible to round a double to a certain number of decimal places
View 1 Replies
May 14, 2011
I'm creating a maths program and when it comes to division it's giving me .34216 as answeres which isn't what I want.I was thinking declaring the textbox the answer appears in as a single.It's not working out though and it's still using decimal points.I was told by my teacher to declare it as an integer so I tried that too, it's not working out also. I figured based on the code, I would be declaring array3() as the single or integer since that's the textbox the answer will be output into. [code]
View 2 Replies
Sep 17, 2009
I am writing a program that has 2 text boxes & 1 button in it.The first text box is to enter a number then hit the calculate button and it outputs to the 2nd text box after doing a math problem.I then need it to round to 2 decimal spots.I used to use Visual Basic 6 but don't have access to that any longer.So now I'm using Visual Basic 2008.Here is my code, but the math.round isn't working.[code].....
View 1 Replies
Apr 29, 2009
I need a function which will Round a number UP to the specified decimal precision, exactly the same as how Excel's RoundUp function works:
Roundup(dblVal, intDecPlaces)
So I need the following:
Roundup(0.896523, 4)
would return
0.8966
However, everything i've tried/found simply rounds to the nearest whole integer, or returns a normal rounded value, hence the above would return
0.8965
I've tried the following:
Math.Round(dblval, intPrecision, midpointrounding.awayfromzero)
' and
Math.Round(dblval, intPrecision, midpointrounding.toeven)
And even custom functions, such as:
Public Function RoundUp(ByVal varValue As Object, _
ByVal iNum As Integer) As Double
'ignore the data types here, I was playing to see 'if changing any of the data types would swing 'the results (knowing full well they wouldnt make 'a difference, thats how fed up with this I am!)
Dim lNum As Long, xVal As Double, xVar As Object
xVar = Fix(varValue)
[CODE]...
I've even looked at converting this to a string, looking at the Xth decimal place, and incrementing it up by 1, then converting it back to a double, while this works (sort of) it seems to be a very roughshod way of doing it, and I'd rather do it mathematically than with lots of data conversion.
View 6 Replies
Jul 23, 2011
I would like to round a number that is a whole number, but i would like to round it to the nearest value of N So if N was 5 then it would round the number to the nearest factor of 5 if N was 6 then it would round the number to the nearest factor of 6 and so on....
View 4 Replies
Dec 13, 2011
i am trying to round up every number to the next whole number even if the number is of lower decimal....
for example:
round 1.1 up to 2
round 1.4 up to 2
round 1.7 up to 2
[Code].....
View 2 Replies
May 29, 2008
I have a combobox. The data that it binds to should be:
AcctID AcctName
10 Main
11 Old
[code].....
View 3 Replies
Apr 22, 2009
I am working in excel trying to setup a function involving multiplying a cell by a set number and then having the result round to the nearest 10. Here's the beginning of my function statement fx=e3*1.026. say the result is 8654, I need it to round to 8650. Also if it comes back 8655, I need it to round to 8660. I have about 2,000 records I need to do this to so I was hoping that one formula or statement could be used for all my data.
View 2 Replies
Sep 23, 2010
Part 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]...
View 6 Replies
Sep 14, 2011
var queryString = string.Format("filename={0}&filestream={1}&append={2)", fileName, Convert.ToBase64String(b, 0, bytesRead).ToString(), 1);
above line of code giving error 'Input string was not in a correct format.'
View 2 Replies
Oct 13, 2011
I have an DataGridWeiw as an result table for a little racing game.The grid is sorting itself everytime a new value is added in a "points" column using the following code. TableDG.Sort(Column2, System.ComponentModel.ListSortDirection.Descending)
And it works fine as long as "points" not exeed 9. eg: I want the datagrid to sort "10" or above as greater than 9. Not putting the "10" or above last in the list?How can i do that?
And is there any way to get rid of the "grey" marked first row?
View 3 Replies
Feb 15, 2011
I have a form (FRMQUESTIONNAIRE). It contains, a listview table, a panel and picturebox, 2 combobox, 10 questions with 5 radio buttons each question ( A survey),A log number id (I just used Label in here) and 2 buttons ( save and skip).
Problem: When I click one item in listview table, the picture captured realted to the item click in listview table will be shown in panel beside it. However, the problem start to happen when the log ID is not appear accordingly based on user selection on listview table.
What I reckon start of the problem: - Previously The listview table(listview1) in frmquestionnaire was in frmqlist(another form). But to suit user requirement, it has to combined with frmquestionnaire. In frmqlist, I use a label Image. This form contains the similar details in frmquestionanire except there are no 2 combobox, 10 questions with 5 radio buttons each question ( A survey),A log number id (I just used Label in here) and 2 buttons ( save and skip) But it have a button(Proceed to survey). Having said that, when user click an item in listview(Frmqlist), the picture will be shown beside it. User will click button proceed to survey and frmquestionnaire will pop up. Here, It shows the correct Log ID based on user selection in frmqlist.
But now....
I have combine everything in frmquestionnaire. I am facing as the LOG ID is not showing according to the selection. As a result, I can't save the questionnaire answer as well as this log will be used to save in database.
[Code]....
View 2 Replies
Jun 21, 2010
I am having issues getting my application to display the correct number of asterisks per store. Also, I cannot figure out how to get each store to display in the list box.
' BarChart: Chapter 5 #6
' Program Discription: This application prompts the user to enter today's sales
' for five stores. The program then displays a bar graph comparing each store's
' sales. The bar graph is made up of asterisks in a list box. Each asterisk
' represents $100 in sales.
[Code].....
View 1 Replies