Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to format a textbox on a windows form

Posted on 2003-03-05
8
Medium Priority
?
160 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:itsos
  • 4
  • 3
8 Comments
 

Accepted Solution

by:
bhnv9 earned 100 total points
ID: 8078123
Format(Text1.Text, "###,###,###")

For the full list of formats go to the msdn help.
Title:
Formatting Numbers, Dates, and Times
0
 

Author Comment

by:itsos
ID: 8078420
Thank you bhnv9 for your quick reply.  Your suggestion doesn't seem to work for me.  This is what I have done:

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
0
 

Expert Comment

by:bhnv9
ID: 8078610
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:itsos
ID: 8078770
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

0
 

Expert Comment

by:bhnv9
ID: 8079646
Sorry, don't know .net. Didn't realize that was what you were using
0
 
LVL 3

Expert Comment

by:happel
ID: 8079669
Did you check your language dependant settings?
I mean the thousand and decimal separators.
0
 

Author Comment

by:itsos
ID: 8086491
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
0
 

Author Comment

by:itsos
ID: 8086496
Close enough...

Cheers.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question