zoukankan      html  css  js  c++  java
  • VB6利用正则表达式验证IP地址合法性

    ‘------IP 地址

    Public Function isValidIpAddress(strIpAddress As String) As Boolean
    Dim reg As New RegExp, i As Integer
       reg.IgnoreCase = True
       reg.Global = True
       reg.MultiLine = True
       reg.Pattern = "^d{1,3}.d{1,3}.d{1,3}.d{1,3}$"
    
    isValidIpAddress = reg.Test(strIpAddress)
    
    If isValidIpAddress = True Then
    Dim strArr() As String
    strArr = Split(strIpAddress, ".")
    
    For i = 0 To UBound(strArr)
       isValidIpAddress = isValidIpAddress And isValidIpNumber(strArr(i))
          Next i
      End If
    End Function
    Private Function isValidIpNumber(strNumber As String)
        Dim ipnum As Integer
        ipnum = CInt(strNumber)
    
        isValidIpNumber = (ipnum < 256)
    End Function
    
  • 相关阅读:
    437. Path Sum III
    51. N-Queens
    dfs 感悟
    Topological Sorting
    138 Copy List with Random Pointer
    130. Surrounded Regions
    The sum problem
    A + B Again
    Rectangles
    An easy problem
  • 原文地址:https://www.cnblogs.com/xbj-hyml/p/5533462.html
Copyright © 2011-2022 走看看