How to find out if IP address is valid

I want to allow the user to type in an IP address into a textbox and then verify that it's ok (a valid structure).
Is there a quick function that will tell me that
"193.132.324.23" is ok
and "13r.675.s.78" has a problem
I've written code that will check for the dots and then by finding there location, use it to breakown the ip address so that I have the following
var1 = "13r"
var2 = "675"
var3 = "s"
var4 = "78"
I was then trying the following
if val(var1) < 0 or val(var2)>999 then
msgbox"problem"
endif
but as the val function returns 0(zero) if it gets something like "s" then this wont work for me.
Any quicker methods would be appreciated

Paul
PaulBlackAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
In your code that checks for dots, why don't you also check for non-numeric values and either strip them out or return and error?
0
telebasicsCommented:
Use an masked edit control
with this mask

MaskEdBox1.Mask="###.###.###.###"
MaskEdBox1.MaxLength=15

So now only things like

234.365.10.1 can be entered
So use you own check to check if they are correct
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erick37Commented:
Why not use a Masked Edit Control?
0
PaulBlackAuthor Commented:
Thanks
if telebasics changes the comment to an answer then you can have the points
Cheers
Paul
0
smeggheadCommented:
Hey Paul, just click on the 'Accept comment as answer' to the right of the header. Saves telebasics from having to post an answer....

PS. It's probably also worth checking that the numbers within the IP address are less than 256, the possible numbers range from 0-255, not 0-999. I'm not sure if you can use the masked edit box for this, I've not used it much before.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.