Mask in VB.Net
-
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
-
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
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
-
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
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:)
-
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:)
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 theString.Format
method for that. Text Property (MaskedEdit Control)[^] RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome