2010年7月22日 星期四

控制金額小數點



程式內運用string.format(也可運用math.round) 來處理控制計算後的小數點
若在sql就只剩下round了
本例採用string.format

code
--------------------
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Decimal = TextBox2.Text
Dim b As Decimal = TextBox3.Text
Dim d As Integer = TextBox4.Text
Dim c As Decimal = String.Format("{0:N" & d & "}", a * b)
TextBox1.Text = c
End Sub
End Class

沒有留言:

張貼留言