[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MaskedTextBox removes preceding 0

Posted on 2010-01-07
9
Medium Priority
?
586 Views
Last Modified: 2013-11-08
I have a masked text box, for Birthdate. In the when grabbing and formatiing the data it is a date with preceeding zero's if necessary (05/05/2005)

However when it gets inseted into the masked text box it converts the aboexample date to look like 55/20/05__

The mask on the text box is 00/00/0000

Is there some way to get this to work correctly?
0
Comment
Question by:kikimayhay
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 400 total points
ID: 26205813
one way could be format the date as string with format(MM/dd/yyyy).Try it out.
0
 
LVL 9

Assisted Solution

by:magicdlf
magicdlf earned 800 total points
ID: 26206522
http://homepage.ntlworld.com/herring1/format.html
Dates and the MaskedTextBox

I used the supplied date masks and was a little surprised that these did not perform any validation at all, for example you could enter a date of '22/75/0000' or even leave part of the date blank. However, when I looked at the Microsoft Developer Network website this was explained very well and there was a good example. So I decided to try a custom mask calling events as suggested. This works very well and gives as much flexibility in your validation as most people would ever need. It seems a bit of a shame that these weren't incorporated directly into the control. Never mind it has made me re-evaluate my approach to data validation.
0
 
LVL 9

Assisted Solution

by:magicdlf
magicdlf earned 800 total points
ID: 26206526
So how did you input your data 5/5/2005? Copy paste? Manually input? or by a program?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:kikimayhay
ID: 26209977
The Data is coming from a date field in a database table the line that assigns it is:
MaskedTextBox.text = Format(datatable(0)("DOB"), "MM/dd/yyyy")
and I get results as stated above
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 800 total points
ID: 26212315
I have not had time to test this but you may want to do this
MaskedTextBox.text = Format(datatable(0)("DOB"), "MM/dd/yyyy").ToString

0
 

Author Comment

by:kikimayhay
ID: 26212526
I've tried that as well, the really weird thing is I have the same control on another form  in the same program. It pulls the same data from the same table, and is formatted the same, yet somehow it works as intended.
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 800 total points
ID: 26217864
I have seen that happen before in other controls.
Had to delete the control and re-add it again.
0
 

Author Comment

by:kikimayhay
ID: 26294207
Deleting and re-adding the control did not work. I had to delete the form and manually re-add all the controls (copy and pasting logic behind controls).  
I cannot recreate the behaviour. Not sure what was going on but it had to be somewhere within the form itself.
0
 

Author Closing Comment

by:kikimayhay
ID: 31674308
Dispursing evenly among comments
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 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