Masked edit box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Kiernan

    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,"Sh ort Date") to no avail. Format and
    mask properties of the box are set to ##/##/####


  • Rick Rothstein

    #2
    Re: Masked edit box

    > I have a masked edit box which has a value of "8/30/2004", and when i[color=blue]
    > 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[/color]
    the box.[color=blue]
    > I've even tried using format(date,"Sh ort Date") to no avail. Format[/color]
    and[color=blue]
    > mask properties of the box are set to ##/##/####[/color]

    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

    Comment

    • Eric Kiernan

      #3
      Re: Masked edit box

      Thanks. That worked.

      "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
      news:2ZGdneb0Ve AEBazcRVn-gw@comcast.com. ..[color=blue][color=green]
      > > 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[/color]
      > the box.[color=green]
      > > I've even tried using format(date,"Sh ort Date") to no avail. Format[/color]
      > and[color=green]
      > > mask properties of the box are set to ##/##/####[/color]
      >
      > 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
      >[/color]


      Comment

      Working...