sujittalukde
06-23-2008, 11:20 PM
I am using the following code to display the number format on a label named Label5 whenever number is entered to a Textbox named Textbox3
Private Sub TextBox3_Change()
'TextBox3.Text = Format(TextBox3.Value, "[>=10000000]#\,##\,##\,##0;[>=100000]##\,##\,##0;##,##0")
Select Case TextBox3.Text
Case Is >= 1E+15
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 10000000000000#
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 100000000000#
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 1000000000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""000.00")
Case Is >= 10000000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""000.00")
Case Is >= 100000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""000.00")
Case Else
Label5.Caption = Format(TextBox3.Text, "##,###.00")
End Select
End Sub
Now the problem is:
Suppose I want to write a number 12000 and the label should display 12,000 on textbox change event.
But when I press 1 it is going to case else, but next time when I press 2, the code enters into [Case Is >= 10000000000000#] and thus shows number format as ,00,00,00,00,00,012.00 whereas I want to display the same as 12 only on the label5 caption.
Why the code is entering to this case [Case Is >= 10000000000000#] instead of entering into Case else as 12 fits for that case.
Private Sub TextBox3_Change()
'TextBox3.Text = Format(TextBox3.Value, "[>=10000000]#\,##\,##\,##0;[>=100000]##\,##\,##0;##,##0")
Select Case TextBox3.Text
Case Is >= 1E+15
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 10000000000000#
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 100000000000#
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""00"",""00"",""000.00")
Case Is >= 1000000000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""00"",""000.00")
Case Is >= 10000000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""00"",""000.00")
Case Is >= 100000
Label5.Caption = Format(TextBox3.Text, "##"",""00"",""000.00")
Case Else
Label5.Caption = Format(TextBox3.Text, "##,###.00")
End Select
End Sub
Now the problem is:
Suppose I want to write a number 12000 and the label should display 12,000 on textbox change event.
But when I press 1 it is going to case else, but next time when I press 2, the code enters into [Case Is >= 10000000000000#] and thus shows number format as ,00,00,00,00,00,012.00 whereas I want to display the same as 12 only on the label5 caption.
Why the code is entering to this case [Case Is >= 10000000000000#] instead of entering into Case else as 12 fits for that case.