IP Addresses trapping

A

Antonio

I was wondering if someone out there would have a better
way to trap for IP addresses entry. I have a form with 4
text boxes, and one form for the CIDR. When users enter
the IP address bytes, one by one are being auto-entered
into another text box. When the users entered the CIDR,
in the LostFocus event, the IP address is being formatted
to display the range of available IP addresses. This is
quite long to read, I know, and I thank you for your time.
Here is a portion of the procedure:

If IPByte3.Value <= 254 And IPByte4.Value <= 0 And
CIDR.Value = "23" Then
IPRange.Value = IPByte1.Value & "." & IPByte2.Value
& "." & (IPByte3.Value & "-" & _
IPByte3.Value + 1 & "." & IPByte4.Value & "-"
& IPByte4.Value + intCIDR)
ElseIf IPByte4.Value > 0 And CIDR.Value = "23" Then
OutOfRange
DoCmd.CancelEvent
IPByte3.Value = ""
CIDR.Value = ""
IPByte4.Value = ""
IPByte3.SetFocus
ElseIf IPByte3.Value <= 252 And IPByte4.Value <= 0 And
CIDR.Value = "22" Then
IPRange.Value = IPByte1.Value & "." & IPByte2.Value
& "." & (IPByte3.Value & "-" & _
IPByte3.Value + 3 & "." & IPByte4.Value & "-"
& IPByte4.Value + intCIDR)
ElseIf IPByte4.Value > 0 And CIDR.Value = "22" Then
OutOfRange
DoCmd.CancelEvent
IPByte3.Value = ""
IPByte4.Value = ""
CIDR.Value = ""
IPByte3.SetFocus
ElseIf IPByte3.Value <= 248 And IPByte4.Value <= 0 And
CIDR.Value = "21" Then
IPRange.Value = IPByte1.Value & "." & IPByte2.Value
& "." & (IPByte3.Value & "-" & _
IPByte3.Value + 7 & "." & IPByte4.Value & "-"
& IPByte4.Value + intCIDR)
ElseIf IPByte4.Value > 0 And CIDR.Value = "21" Then
OutOfRange
DoCmd.CancelEvent
IPByte3.Value = ""
IPByte4.Value = ""
CIDR.Value = ""
IPByte3.SetFocus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top