Help - Search - Members - Calendar
Full Version: Rounding In Visual Basic
Sal's RuneScape Forum > Everything... Not RuneScape > Tech Talk > Programming & Web Development
Synapsi
I'm making a skill calculator and for the amount of items needed to level up, it comes in decimals. So, any ways to round my final answer up to the nearest whole number?
lilshu
I remember something like... int()

Does that help at all? blush.gif
Synapsi
I put it in as:
CODE
txtn1.Text = CStr(Int(txtn1.Text))

Is that how it is supposed to work?
Because then I get:
CODE
Conversion from string "" to type 'Double' is not valid.

On the last line of that code.
Colinross
I would go along these lines:

CODE
Private Sub Command1_Click()
Dim number As Integer

number = 856 / 45 + 0.5
Text1.Text = number

End Sub


As long as you define the variable as an integer it shouldn't have decimal places
As for adding "0.5", that will make sure that the number will always round up, which you will need it to round up for a skill calculator

From my test it works so... tongue.gif
Synapsi
From what I've seen, that works. biggrin.gif
I thank you, let's see how it compares to what Sal's' gets.

Edit: Yep, I now have a complete, visual basic, mining calculator. biggrin.gif
Agent F
QUOTE(Synapsi @ Oct 31 2007 at 10:35 PM) *
From what I've seen, that works. biggrin.gif
I thank you, let's see how it compares to what Sal's' gets.

Edit: Yep, I now have a complete, visual basic, mining calculator. biggrin.gif

Did you correctly test for your values within the game? I recently started a new character and started mining copper and tin. I realized that the values used in the calculators among 4 different helpsites were wrong. It may have been the smithing calculator though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.