Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Validate IP Address

On Fri, 11 Sep 2009 17:14:02 -0700, HarryisTrying
wrote:

This works but it doesn't reject input with more than 4 octets
xxx.xxx.xxx.xxx.yyy

Thanks and I will use this to try and learn some more
--
Thank You


Here's another approach that will reject

1.1.1.1.1

but accept

1.1.1.1.1 1.1.1.1

since the latter "contains" a valid IP address that is separated from the
invalid construct:

===============================
Option Explicit
Function containsIP(str As String) As Boolean
Dim re As Object

Set re = CreateObject("vbscript.regexp")
re.Pattern = _
"(?:^|\s)\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b(?:\s|$)"

containsIP = re.Test(str)
Set re = Nothing
End Function
===========================
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate Email address entry Rayasiom Excel Discussion (Misc queries) 2 May 31st 07 10:36 AM
Validate an Email Address Duncan[_5_] Excel Programming 1 April 26th 06 07:36 PM
Validate email address Ken Valenti Excel Programming 1 January 24th 06 12:31 AM
Validate an email address BethP Excel Programming 1 July 12th 05 11:51 PM
relative address in validate miro Excel Programming 4 November 30th 04 07:44 AM


All times are GMT +1. The time now is 11:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"