Advertisement
ASP_Volume2 Internet/ HTML #35428

Dotless IP Address

This will convert an existing IP address into an IP address without any periods (dotless IP). Although the dotless IP code is useless, the CountWords and GetWord functions are very useful. CountWords will count the number of words in a string and GetWord will get that specified word. You can also choose what character seperates the words, such as a space or period. GetWord was created by James Lewis with some modification.

AI

Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kaynak Kod
original-source
' ----- for vb6 users -----
Function IP_Dotless#(ByVal ipAddress As String)
  Dim numArray As Variant
  
  numArray = Split(ipAddress$, ".")
  IP_Dotless = (numArray(0) * 256 ^ 3) + _
         (numArray(1) * 256 ^ 2) + _
         (numArray(2) * 256 ^ 1) + _
         numArray(3)
End Function
' ----- for vb5 and below users -----
Function IP_Dotless# (ByVal ipAddress As String)
IP_Dotless = (Val(GetWord$(ipAddress, 1, ".")) * 256 ^ 3) + (Val(GetWord$(ipAddress, 2, ".")) * 256 ^ 2) + (Val(GetWord$(ipAddress, 3, ".")) * 256 ^ 1) + (Val(GetWord$(ipAddress, 4, ".")))
End Function
Function CountWords& (ByVal inWord$, ByVal inSep$)
Dim strTempA$
Dim strTempB$
Dim lngTempA&
Dim lngTempB&
Dim lngRet&
On Error Resume Next
inWord$ = inWord$ + inSep$
For lngRet& = 1 To Len(inWord$)
strTempA$ = Mid$(inWord$, lngRet&, Len(inSep$))
strTempB$ = strTempB$ + strTempA$
If strTempA$ = inSep$ Then
lngTempA& = Len(strTempB$) - Len(inSep$)
strTempB$ = Left$(strTempB$, lngTempA&)
lngTempB& = lngTempB& + 1
strTempB$ = ""
End If
Next lngRet&
CountWords& = lngTempB&
End Function
Function GetWord$ (ByVal inWord$, ByVal inCount&, ByVal inSep$)
Dim strTempA$
Dim strTempB$
Dim lngTempA&
Dim lngTempB&
Dim lngRet&
On Error Resume Next
inWord$ = inWord$ + inSep$
For lngRet& = 1 To Len(inWord$)
strTempA$ = Mid$(inWord$, lngRet&, Len(inSep$))
strTempB$ = strTempB$ + strTempA$
If strTempA$ = inSep$ Then
lngTempA& = Len(strTempB$) - 1
strTempB$ = Left$(strTempB$, lngTempA&)
lngTempB& = lngTempB& + 1
If lngTempB& = inCount& Then
GetWord$ = strTempB$
Exit Function
End If
strTempB$ = ""
End If
Next lngRet&
GetWord$ = ""
End Function
Upload
Function CLngIP(ByVal asNewIP)
	Dim lnResults
	Dim lnIndex
	Dim lnIpAry
	' Split the IP address using the dot as a delimiter
	lnIpAry = Split(asNewIP, ".", 4)
	' Loop through each number in the IP address
	For lnIndex = 0 To 3
		
		' If we are not working with the last number...
		If Not lnIndex = 3 Then
			
			' Convert the number to a value range that can be parsed from the others
			lnIpAry(lnIndex) = lnIpAry(lnIndex) * (256 ^ (3 - lnIndex))
		
		End If
		
		' Add the number to the results
		lnResults = lnResults + lnIpAry(lnIndex)
	
	Next
	' If storing number within an Access Database,
	' The variable type "Long" ranges from -2147483648 to 2147483647
	' You will need to subtract 2147483648 from the number
	' before querying the database.
	
	' lnResults = lnResults - 2147483648
	' Return the results
	CLngIP = lnResults
End Function
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı