0

i need to format my textbox result into two decimal places after i divide two textbox
here is my code.

If String.IsNullOrEmpty(txtMonthly.Text) OrElse String.IsNullOrEmpty(txtdr.Text) Then Exit Sub
    If Not IsNumeric(txtMonthly.Text) OrElse Not IsNumeric(txtdr.Text) Then Exit Sub
    txtDaily.Text = CDbl(txtMonthly.Text) / CDbl(txtdr.Text)

Thanks in Advance

3
Contributors
2
Replies
14
Views
2 Weeks
Discussion Span
Last Post by Reverend Jim
0

You are assigning a double to a string.

Should probably be like:
dim num as double

num=CDbl(txtMonthly.Text) / CDbl(txtdr.Text)

2

You could use

FormatNumber(x, 2)

where x is the value you wabt to format and 2 is the number of decimal places.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.