• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Problem with decimals values

Status
Not open for further replies.
Initiate Mage
Joined
Dec 29, 2013
Messages
1
Reaction score
0
First of all, im developing a program in vb.net, but the code is basically C, if its not allowed, tell me and I deleted the post, im new here!

I have the following problem:

I have 3 textboxes (Txtbox 6, 4 and 3)
I wanna do the following thing:
Textbox 6 = Textbox 3 / (Textbox4 * Textbox4)
I tried the following code:
Static c As Integer
Static d As Integer
c = TextBox4.Text * TextBox4.Text
d = TextBox3.Text
If c >= 0 <= 1000 Then
End If
If d >= 0 <= 1000 Then
End If
TextBox6.Text = d / c
But the problem is that the result is wrong (the program is only considering the entire values, not the values after the comma, for example:
Textbox 6 = 75 / 1,80 * 1,80
Textbox 6 = 75 / 3,24 (the program is considering 3, instead of 3,24)
So the result is (by the program): 25
And the correct result is: 23,1
Any clues what im doing wrong?




Nvm, I found the error and changed the code:


Static c As Decimal
Static d As Decimal


c = TextBox4.Text * TextBox4.Text
d = TextBox3.Text


If c >= 0 <= 1000 Then


End If
If d >= 0 <= 1000 Then


End If




TextBox6.Text = d / c
 
Status
Not open for further replies.
Back
Top