?
Solved

How to format a textbox on a windows form

Posted on 2003-03-05
8
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

764 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