Hi Taghreed
It depends how you define "the next available IP address".
An IP address is simply a 32-bit unsigned integer, which can be stored as a
long integer in Access. If you add 1 to it, you have another IP address.
Whether this is the "next available" one is another matter.
The following functions might be useful to convert between the long integer
and string forms of the IP address:
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
source As Any, _
ByVal Length As Long)
Public Function FormatIPAddress(IP As Long) As String
Dim aIP(3) As Byte
CopyMemory aIP(0), IP, 4
FormatIPAddress = aIP(3) & "." & aIP(2) & "." & aIP(1) & "." & aIP(0)
End Function
Public Function EncodeIPAddress(sIP As String) As Long
Dim aIP(3) As Byte, IP As Long, sByte As String
Dim iByte As Integer, iDot As Integer, iNext As Integer
iNext = 1
For iByte = 1 To 4
If iByte = 4 Then
sByte = Mid(sIP, iNext)
Else
iDot = InStr(iNext, sIP, ".")
If iDot = 0 Then GoTo InvalidIP
sByte = Mid(sIP, iNext, iDot - iNext)
iNext = iDot + 1
End If
If Not IsNumeric(sByte) Then GoTo InvalidIP
If Val(sByte) < 0 Or Val(sByte) > 255 Then GoTo InvalidIP
aIP(4 - iByte) = Val(sByte)
Next
CopyMemory IP, aIP(0), 4
EncodeIPAddress = IP
Exit Function
InvalidIP:
' do whatever you want here
Err.Raise 5, , "Invalid IP address"
End Function
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.