471,073 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Masked edit box

I have a masked edit box which has a value of "8/30/2004", and when i
programically set the value to mskedbox1=date, the vb blows up with an
invalid property value error. any ideas? It works ok if i set
mskedbox1="08/30/2004", but I can't seem to get the date value into the box.
I've even tried using format(date,"Short Date") to no avail. Format and
mask properties of the box are set to ##/##/####
Jul 17 '05 #1
2 8926
> I have a masked edit box which has a value of "8/30/2004", and when i
programically set the value to mskedbox1=date, the vb blows up with an
invalid property value error. any ideas? It works ok if i set
mskedbox1="08/30/2004", but I can't seem to get the date value into the box. I've even tried using format(date,"Short Date") to no avail. Format and mask properties of the box are set to ##/##/####


Don't set the Format property (only set the Mask property) and assign
the Date this way...

mskedbox1.Text = Format$(Date, "mm/dd/yyyy")

Note that I specify the Text property rather than assume VB will apply
it as the default property. Do so will make reading your code much
easier six months to a year from now when you (or, if you are working in
a company, the person assigned to the task) have to modify your code. As
for the form of the Format function's specification string... it much
match the format of the Mask property character for character (that
means leading zeroes must be preserved).

Rick - MVP

Jul 17 '05 #2
Thanks. That worked.

"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:2Z********************@comcast.com...
I have a masked edit box which has a value of "8/30/2004", and when i
programically set the value to mskedbox1=date, the vb blows up with an
invalid property value error. any ideas? It works ok if i set
mskedbox1="08/30/2004", but I can't seem to get the date value into

the box.
I've even tried using format(date,"Short Date") to no avail. Format

and
mask properties of the box are set to ##/##/####


Don't set the Format property (only set the Mask property) and assign
the Date this way...

mskedbox1.Text = Format$(Date, "mm/dd/yyyy")

Note that I specify the Text property rather than assume VB will apply
it as the default property. Do so will make reading your code much
easier six months to a year from now when you (or, if you are working in
a company, the person assigned to the task) have to modify your code. As
for the form of the Format function's specification string... it much
match the format of the Mask property character for character (that
means leading zeroes must be preserved).

Rick - MVP

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by metridevkk | last post: by
1 post views Thread by larry | last post: by
reply views Thread by jin | last post: by
7 posts views Thread by DazedAndConfused | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.