Mask and dates

  • Thread starter Thread starter path
  • Start date Start date
P

path

Hello all
I'm programming in a Windows form (VB 2005).
I use the MaskedTextBox control. I use the slash "/" as separator date.
When I retrieve data from a database in another workstation the separator
changes by depending the separator OS by defualt "-" or "."
How can I use the MaskedTextBox control always with "/"... or there is
anoter solution?

Thanks in advanced.
henpat
 
Hello all
I'm programming in a Windows form (VB 2005).
I use the MaskedTextBox control. I use the slash "/" as separator date.
When I retrieve data from a database in another workstation the separator
changes by depending the separator OS by defualt "-" or "."
How can I use the MaskedTextBox control always with "/"... or there is
anoter solution?

Thanks in advanced.
henpat

There is indeed! When it comes to inputing dates try and make use of the
calendar or the datepicker. It solves many common problems such as:
- Validation
- Use of separators
- Invalid dates e.g. 30 February
 
Can you format the date into the MaskedTextBox control?
I used to use that in VB6 a lot, but haven't used it in .Net yet.
Something like maskedtextbox.text = format(myDate, "mm/dd/yy")
This must match the mask you have defined, and it forces
the incoming data into the same format. Does that help?

Robin S.
 
Something like maskedtextbox.text = format(myDate, "mm/dd/yy")

AFAIK format() doesn't work on strings. Instead use:

maskedtextbox.text = mydate.tostring("MM/dd/yy")

Thanks,

Seth Rowe
 
Thanks for providing the syntax for what I was going for!
Robin S.
-----------------------------
 
Back
Top