[英]textbox not showing decimal places\
從用戶表單
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個小數位,但它們顯示為.00,而不是.84。
誰能幫我解決這個問題?
您已將AA
, BB
, CC
和DD
為整數。 整數只能存儲整數。 根據此數據表示的內容,您可以使用Decimal
或Double
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.