【发布时间】:2017-10-06 03:01:49
【问题描述】:
来自用户表单
numberupdown 1 是 F,
numberupdown 2 是 L,
numberupdown 3 是 W,
文本框是CF,
计算是button1。
计算公式为
F-(F*(L^2)/(W^2)
基本上这需要灌溉枢轴的流量,并冲出转弯所需的流量。
输入数字是公制,结果是英制美国 GPM。
我已经把它翻译成:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim AA, BB, CC, DD As Integer 'sets up the variables
AA = F.Value * 15.8503 'takes the value in f and converts it to US GPM
BB = L.Value * 3.2808 'takes the value in f and converts it to feet
CC = W.Value * 3.2808 'takes the value in f and converts it to feet
DD = AA - (AA * (Math.Pow(BB, 2) / (Math.Pow(CC, 2)))) 'the math bit
CF.Text = String.Format("{0:n2}", DD) 'puts result in this textbox
End Sub
我追求的最终数字是 323.84,但它坚持将结果四舍五入到 324
我把 string.format("{0:n2}",DD) 显示为 2 位小数,但它们显示为 0.00,而不是 0.84。
谁能帮我解决这个问题?
【问题讨论】:
-
如果您使用
Option Strict On,它会指出尝试将浮点值分配给整数变量等问题。但是,它不会指出角流单位的标签应该是“US GPM”,而不是“l/s”。