|
||||||||||||||
The FormatNumber function returns a formatted string representation for a number. The Syntax is: FormatNumber(expression _ [,digits_after_decimal] _ [,include_leading_zero] _ [,use_parens_if_negative] _ [,groups_digits] ) Where:
Examples:
This example uses the following code to display these examples in a TextBox. |
||||||||||||||
Private Sub Form1_Load(ByVal sender As System.Object,ByVal _
e As System.EventArgs) Handles MyBase.Load
Dim txt As String
Dim x As Single
x = 1.23456
txt &= "FormatNumber(" & x.ToString() & ",2) = " & _
FormatNumber(x,2) & vbCrLf
x = 0.123456
txt &= "FormatNumber(" & x.ToString() & "," & _
"TriState.False) = " & FormatNumber(x,_
TriState.False) & vbCrLf
txt &= "FormatNumber(" & x.ToString() & "," & _
"TriState.True) = " & FormatNumber(x,_
TriState.True) & vbCrLf
x = -12345.12345
txt &= "FormatNumber(" & x.ToString() & ",_
TriState.True) & vbCrLf
txt &= "FormatNumber(" & x.ToString() & "," & _
"TriState.True,TriState.False) = " & _
FormatNumber(x,TriState.False) _
& vbCrLf
txtResult.Text = txt
txtResult.Select(0,0)
End Sub |
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。