Click here to Skip to main content
14,836,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please help,
How can I read a part of a maskedtextbox? for example if the data entered by the user is "123-456-789-444", I would like to assign the second masked item ("456") to label1.text
Any help will be appreciated.

1 solution

You can do it by String.Split() method.
Here is the solution for you.

string maskStr = "123-456-789-444";
        int count = maskStr.Split('-').Length - 1;
        string[] masks = new string[count];
        masks = maskStr.Split('-');
        label1.Text = masks[1];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900