Public Function ConvertBinToIP(strBin As String) As String
  On Error Resume Next
  Dim pos As Integer, binarray, tempnetid As String, ix As Integer, x As Integer, y As Integer, z As String
  strBin = strBin & "."
  binarray = Split(strBin, ".")
  For ix = 0 To UBound(binarray) - 1
    x = 0
    For y = 7 To 0 Step -1
      If Mid(StrReverse(binarray(ix)), y + 1, 1) = "1" Then
        x = x + BA(y)
      Else
        x = x
      End If
    Next y
    z = z & CStr(x) & "."
  Next ix
  ConvertBinToIP = Left(z, Len(z) - 1)
End Function

解决方案 »

  1.   

    strBin就是要转换的二进制数据。
      

  2.   

    可是你的pos是什么?,我想的是把二进制转换成十进制啊,我给了你那么多分,你帮人帮到底哦
      

  3.   

    重新来过Public Function ConvertBinToIP(strBin As String) As String
    Dim bArray() As String, tmpVal As Integer
    Dim iCount As Integer, iPos As Integer
    On Error Resume Next
        strBin = strBin & "."
        bArray = Split(strBin, ".")
        
        For iCount = 0 To UBound(bArray) - 1
            tmpVal = 0
            For iPos = 1 To Len(bArray(iCount))
                tmpVal = tmpVal + Val(Mid$(bArray(iCount), iPos, 1)) * (2 ^ (Len(bArray(iCount)) - iPos))
            Next iPos
            ConvertBinToIP = ConvertBinToIP & CStr(tmpVal) & "."
        Next iCount
        ConvertBinToIP = Mid$(ConvertBinToIP, 1, Len(ConvertBinToIP) - 1)
    End Function