Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Mask in VB.Net

Mask in VB.Net

Scheduled Pinned Locked Moved Visual Basic
csharpasp-netdatabasehelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Britnt7
    wrote on last edited by
    #1

    I liked how the masktextbox in vb6 works. Is there anything similar to that in vb.net? I am pretty much trying to mask a phone number to make it (###)###-####. Is this possible to do in vb.net?:doh: This is what I am doing now:

    txtHome.Text = Microsoft.VisualBasic.Left(strHome, 3) & "-" & Microsoft.VisualBasic.Mid(strHome, 4, 3) & "-" & Microsoft.VisualBasic.Right(strHome, 4)

    which produces ###-###-####. There has to be another way to do this. It is working this way but when I save back to the database, I have to unmask it(which I don't like). Please help. Thanks:) Beginner in ASP.Net and VB.Net

    D 1 Reply Last reply
    0
    • B Britnt7

      I liked how the masktextbox in vb6 works. Is there anything similar to that in vb.net? I am pretty much trying to mask a phone number to make it (###)###-####. Is this possible to do in vb.net?:doh: This is what I am doing now:

      txtHome.Text = Microsoft.VisualBasic.Left(strHome, 3) & "-" & Microsoft.VisualBasic.Mid(strHome, 4, 3) & "-" & Microsoft.VisualBasic.Right(strHome, 4)

      which produces ###-###-####. There has to be another way to do this. It is working this way but when I save back to the database, I have to unmask it(which I don't like). Please help. Thanks:) Beginner in ASP.Net and VB.Net

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Well, there is no Masked Edit class in the .NET BCL. At least, not yet... You can still use the Masked Edit control from VB6 though. If MSMASK32.OCX on your machine and registered, all you need to do is add it to the ToolBox. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      B 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Well, there is no Masked Edit class in the .NET BCL. At least, not yet... You can still use the Masked Edit control from VB6 though. If MSMASK32.OCX on your machine and registered, all you need to do is add it to the ToolBox. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        B Offline
        B Offline
        Britnt7
        wrote on last edited by
        #3

        Dave Kreskowiak wrote: You can still use the Masked Edit control from VB6 though. If MSMASK32.OCX on your machine and registered, all you need to do is add it to the ToolBox. I tried this and all seemed great but when I went to fill the masked edit control with text, it never displays any text. Is there something that I need to set or change in the control? The only thing I did was change the mask to (###)###-####, then filled it with text txtNumber.Text = "1234567899". Nothing happens.:doh: Any suggestions? Thanks:)

        D 1 Reply Last reply
        0
        • B Britnt7

          Dave Kreskowiak wrote: You can still use the Masked Edit control from VB6 though. If MSMASK32.OCX on your machine and registered, all you need to do is add it to the ToolBox. I tried this and all seemed great but when I went to fill the masked edit control with text, it never displays any text. Is there something that I need to set or change in the control? The only thing I did was change the mask to (###)###-####, then filled it with text txtNumber.Text = "1234567899". Nothing happens.:doh: Any suggestions? Thanks:)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          That's because when you use the .Text property, the text entered must match the mask format exactly. If not, you won't see anything. You can't use the MaskedEdit control to format the data for you. You have to use the String.Format method for that. Text Property (MaskedEdit Control)[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups