itsos
asked on
How to format a textbox on a windows form
How can I format a textbox on a windows form and datagrid to display a number with the following format
500,000
I'm connecting to an Access database and the field is displayed correctly in the database. However on my windows form and datagrid it looks like this:
500000
Hope somebody can help me.
Kind regards,
Itsos
500,000
I'm connecting to an Access database and the field is displayed correctly in the database. However on my windows form and datagrid it looks like this:
500000
Hope somebody can help me.
Kind regards,
Itsos
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Format(Text1.Text, "###,###,###") changes the text already in the textbox.
If you want that the textbox will have a data format use the design property "dataformat" and custemize it to have a 1000 separator
If you want that the textbox will have a data format use the design property "dataformat" and custemize it to have a 1000 separator
ASKER
Hi again,
Thanks for your reply.
Format(Text1.Text, "###,###,###") does not change the text that is already in the textbox. The value is still shown as 500000.
Also there is no "dataformat" property in Visual Basic .NET. Do you know the equivalent in .NET?
Kind regards,
itsos
Thanks for your reply.
Format(Text1.Text, "###,###,###") does not change the text that is already in the textbox. The value is still shown as 500000.
Also there is no "dataformat" property in Visual Basic .NET. Do you know the equivalent in .NET?
Kind regards,
itsos
Sorry, don't know .net. Didn't realize that was what you were using
Did you check your language dependant settings?
I mean the thousand and decimal separators.
I mean the thousand and decimal separators.
ASKER
I have solved my problem with the following code:
Private Sub Textbox1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox1.Validated
Textbox1.Text = Format(Val(Textbox1.Text), "###,###,###,###")
End Sub
Thanks for your input...
Kind regards,
itsos
Private Sub Textbox1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Textbox1.Validated
Textbox1.Text = Format(Val(Textbox1.Text),
End Sub
Thanks for your input...
Kind regards,
itsos
ASKER
Close enough...
Cheers.
Cheers.
ASKER
Private Sub InitializeTextBox()
Format(Text1.Text, "###,###,###")
End Sub
Private Sub frmCustomers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeTextBox()
End Sub
Any suggestions??
Kind regards,
itsos