Question Textbox custom number format

tqmd1

Well-known member
Joined
Dec 5, 2009
Messages
60
Programming Experience
Beginner
Dear Experts,
How to display INT value in textbox1 in this format
45,75,147.45
I do not want to use MaskedTextbox
Please help
 
Dear Sir,

When I enter data into textbox1, i need codes for TextBox1_TextChanged event that while typing data must display as in this format

45,75,147.45

(comma & decimal)

Please help
 
This makes absolutely no sense. You are not getting any responses because no one here is a mindreader, and neither is your computer.

Exactly what is the TextChanged event looking for? It is monitoring every single new input that is entered. What is it expecting to see or do? Why can't the user simply enter the numbers as stated?

Maybe the TextChanged event is not what you need. Exactly where is the input coming from? Are you getting the input of a number from somewhere and expecting it to concatenate on to whatever is already in the textbox? In that case, the input should be coming from another source, and the code should be something like this (NOT entered in the textbox itself):

If Textbox1.Text <> "" Then
Textbox1.Text &= ", " & newnum.ToString()
Else
Textbox1.Text = newnum.ToString()
End If
 
If you something to validate the text to a certain format, regex maybe the solution. You can use this in the textchanged event or the validating event (can add the e.cancel here).
This is an example:
VB.NET:
If Textbox1.TextLength > 0 Then
      If Regex.IsMatch(Textbox1.Text, "(\d{2}):([0-5]{1}\d{1}):([0-5]{1}\d{1})") Then
        lbFormat.Text = "Correct Format"
        btnAddValue.Enabled = True
      Else
        lbFormat.Text = "Incorrect Format"
        btnAddValue.Enabled = False
      End If
Else : lbFormat.Text = "" : btnAddValue.Enabled = False
End If
Your Regex pattern would be \d{2},\d{2},\d{3}.\d{2}.

Is this what you mean?
 
Back
Top