How ca i codec a Textbox that only a "valied IP Adress" can be insert? only numbers 0 and <256.
Printable View
How ca i codec a Textbox that only a "valied IP Adress" can be insert? only numbers 0 and <256.
Split the IP address up into its 4 numbers, using the InStr() and Mid() functions, and then check that each is between 0 - 255. You can use the Val() function to convert a string to a number.
Ca u give me an example? im really a beginner :-))
thx a lot
i need a code for this.....can anybody help me?????
I doing just that in one of my apps.
To break out the address bytes:
And to put it all back together:Code:Dim sIP As String
Dim cntl As Integer
' extract the IP address byte values from gsHost
sIP = gsRHost
cntl = InStr(sIP, ".")
txtIPAddr1.Text = Left$(sIP, cntl - 1)
sIP = Mid$(sIP, cntl + 1)
cntl = InStr(sIP, ".")
txtIPAddr2.Text = Left$(sIP, cntl - 1)
sIP = Mid$(sIP, cntl + 1)
cntl = InStr(sIP, ".")
txtIPAddr3.Text = Left$(sIP, cntl - 1)
sIP = Mid$(sIP, cntl + 1)
txtIPAddr4.Text = sIP
Code:gsRHost = txtIPAddr1.Text & "." & _
txtIPAddr2.Text & "." & _
txtIPAddr3.Text & "." & _
txtIPAddr4.Text