Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, March 15, 2013 6:48 AM
Hi everyone ..
please help me designing a textbox or a masked textvbox for entering only the ipv4 address ..
I have used maskedtextbox and set the mask as..
mask=999.999.999.999
form when run shows--
___.___.___
when I try to enter an ip address as for example :-
10.45.65.1
I have to write :- 010.045.065.001
which I dont want to ..
means a user can press tab to switch on to the net subnet ip address ..
for example ..
10 (tab press). 45(tab press).65(tab press). 1
I dont want to write 0 (zeros)
as well as I dont want user to enter subnet greater than 255..
please tell me how can I achieve my goal ..
All replies (2)
Tuesday, March 19, 2013 9:45 AM ✅Answered
Hi GIFTED,
Please have a look at the article below which could help you.
A C# IP Address Control
http://www.codeproject.com/Articles/9352/A-C-IP-Address-Control
Good day.
Bob Shen
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, March 15, 2013 8:02 AM
Use a common TextBox but plz use a regular Expression to do validation, part of the Regular expression should be this:
1) Plz substitute Tab to "0":
string s = "2\t\t.2\t5.20\t.255";
s = s.Replace('\t', '0');
Console.WriteLine(s);
2) Then use Regex class to check:
Regex reg = new Regex(@"^[1-2]{0,1}[0-5]{0,1}[0-5]{1,3}\.([0-2]{0,1}[0-5]{0,1}[0-5]{1,3}\.){2}[0-2]{0,1}[0-5]{0,1}[0-5]{1,3}$");
Console.WriteLine(reg.Match("255.255.255.0").Success);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats