I have some formulas outputting to a text box. The numbers keep rounding up. How do I stop this?
Printable View
I have some formulas outputting to a text box. The numbers keep rounding up. How do I stop this?
supply the code or we won't know what went wrong
Pi = 3.14159
major = txtmajor.Text
minor = txtminor.Text
t = txtdia.Text
p = txtpitch.Text
z = txtflutes.Text
f = txtchipload.Text
v = txtsfm.Text
cl = txtclearance.Text
n = (v * 12) / (Pi * t) 'rpm
f1 = f * z * n
f2 = f1 * (major - t) / major 'feed
ri = minor / 2
ro = major / 2
re = ((ri - cl) ^ 2 + ro ^ 2) / (2 * ro)
D = 20 / major / p
a = Pi * major / 4
r = a * (Tan(D * (Pi / 180)))
p1 = 1 / p
x = 0
y = (ri - cl) * (-1)
ro1 = ro * (-1)
txtprogram.Text = "N10 G90 G0 X0 Y0 Z0" & vbCrLf & "G91 G41 D" & txtdvalue.Text & " X0 Y" & Format(y, ".0000") & " Z0" & vbCrLf & "G3 X" & Format(ro, ".0000") & " Y" & Format(re, ".0000") & " Z? R" & Format(re, ".0000") & " S" & Format(n, "0.") & " F" & Format(f2, "0.") & vbCrLf & "G3 X0 Y0 Z" & Format(p1, ".0000") & " I" & Format(ro1, ".0000") & " J0" & vbCrLf & "G3 X" & Format(ro1, ".0000") & " Y" & Format(re, ".0000") & " Z? R" & Format(re, ".0000") & vbCrLf & "G0 G40 X0 Y" & Format(y, ".0000") & " Z0" & vbCrLf & "M1"
Whoa! That looks heavy :p
Where's the declarations of each and one of the variables?
looks to me like you are telling them to round up with the Format Functions. Get rid of the formats and they shouldn't round up.