Mask and dates

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

    Mask and dates

    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


  • Rad [Visual C# MVP]

    #2
    Re: Mask and dates

    On Tue, 5 Dec 2006 14:58:53 +0100, path wrote:
    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
    --
    Bits.Bytes

    Comment

    • RobinS

      #3
      Re: Mask and dates

      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.t ext = 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.
      --------------
      "path" <path@msn.comwr ote in message
      news:ONkXBWHGHH A.1216@TK2MSFTN GP05.phx.gbl...
      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
      >

      Comment

      • rowe_newsgroups

        #4
        Re: Mask and dates

        Something like maskedtextbox.t ext = format(myDate, "mm/dd/yy")

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

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

        Thanks,

        Seth Rowe


        RobinS wrote:
        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.t ext = 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.
        --------------
        "path" <path@msn.comwr ote in message
        news:ONkXBWHGHH A.1216@TK2MSFTN GP05.phx.gbl...
        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

        Comment

        • RobinS

          #5
          Re: Mask and dates

          Thanks for providing the syntax for what I was going for!
          Robin S.
          -----------------------------
          "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
          news:1165347530 .230619.82910@f 1g2000cwa.googl egroups.com...
          >Something like maskedtextbox.t ext = format(myDate, "mm/dd/yy")
          >
          AFAIK format() doesn't work on strings. Instead use:
          >
          maskedtextbox.t ext = mydate.tostring ("MM/dd/yy")
          >
          Thanks,
          >
          Seth Rowe
          >
          >
          RobinS wrote:
          >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.t ext = 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.
          >--------------
          >"path" <path@msn.comwr ote in message
          >news:ONkXBWHGH HA.1216@TK2MSFT NGP05.phx.gbl.. .
          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
          >
          >

          Comment

          • henpat

            #6
            Re: Mask and dates

            Thanks a lot for your comments.
            I'll try
            best!
            path
            "RobinS" <RobinS@NoSpam. yah.noneescribi รณ en el mensaje
            news:i5WdndOjnp 7Ed-jYnZ2dnUVZ_h2dn Z2d@comcast.com ...
            Thanks for providing the syntax for what I was going for!
            Robin S.
            -----------------------------
            "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
            news:1165347530 .230619.82910@f 1g2000cwa.googl egroups.com...
            >>Something like maskedtextbox.t ext = format(myDate, "mm/dd/yy")
            >>
            >AFAIK format() doesn't work on strings. Instead use:
            >>
            >maskedtextbox. text = mydate.tostring ("MM/dd/yy")
            >>
            >Thanks,
            >>
            >Seth Rowe
            >>
            >>
            >RobinS wrote:
            >>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.t ext = 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.
            >>--------------
            >>"path" <path@msn.comwr ote in message
            >>news:ONkXBWHG HHA.1216@TK2MSF TNGP05.phx.gbl. ..
            >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
            >>
            >>
            >
            >

            Comment

            Working...