|
I'm still new to VB.NET I am a VFP programmer and I was task to convert the application that I have written to .NET.
I have a bit of dilemma I want to convert the IP Address that is inputted as '10.0.2.1' to '010.000.002.001' as you well know '10.0.2.1' would not sort properly.
In VFP my program will have this snippet:
PADL would pad the address with 'O' if the length of the data between each '.' is less than 3 if the data entered is '10.0.2.1' in the example IP1 = '10' and will be converted to '010' IP2 = '0' and will be converted to '000' IP3 = '2' and will be converted to '002' IP4 = '1' and will be converted to '001' ipaddress = ip1+'.'+ip2+'.'+ip3+'.'+ip4 (010.000.002.001)
Program Snippet:
ip1 = PADL(subSTR(IP_Address,1,AT('.',IP_Address,1)-1),3,'0')
ip2 = PADL(subSTR(IP_Address,AT('.',IP_Address,1)+1,AT('.',IP_Address,2)-4),3,'0')
ip3 = PADL(subSTR(IP_Address,AT('.',IP_Address,2)+1,AT('.',IP_Address,3)-6),3,'0')
ip4 = PADL(alltrim(substr(ip_address,RAT('.',IP_Address,1)+1)),3,'0')
ipaddress = ip1+'.'+ip2+'.'+ip3+'.'+ip4 replace ip_Address WITH ipAddress Can somebody please show me how I can do it in VB.NET.
How do I also validate that the user has inputted a valid IP address. This routine will be used in different pages as well as some pages will contain the textbox for IP Address. My backend is SQL2005 does anybody know how to do it in SQL as an input mask. I would appreciate it if somebody will be able to show by example how I can do this and where can I put it in?
Can I put it in a stored procedure or make it a function...bearing in mind that I should be able to call this from any page and how do I call it?
|