How to create an Input Mask (and necessary code) for an IP Address

R

rich

Hello Everyone,

I would like to create an Input Mask for an IP Address. Can anyone help me
with this?

I've been search the net for a solution but keep coming up with nothing.
Several posting suggest that this will need to be coded, but this is my
weakness. I'm not a true developer and don't know enough VBA.

I think I have an idea on how the logic should go, but I don't know enough
to code it.

Something like this....

Table/Column definition: IP_Address: Text(15); 12 digits + 3 dots.

Logic:
1. user enters the IP address in dot notation format (999.9.9.999).
length of each octet should not matter.

2.


Can anyone offer a solution or point me to some online help?

Thanks in advance,
Rich
 
A

Albert D. Kallal

rich said:
Logic:
1. user enters the IP address in dot notation format (999.9.9.999).
length of each octet should not matter.

Unfornalty, the above REALLY should be entered as:

999.009.009.999

If you don't force a consistant format here, then it really hard to make a
input mask. It also hard to seach for numbers, and also reprots don't
print all that nice when the length is not foreced to be the same.

If you are willing to ALWAYS force users to enter 3 digits, then just use:

000.000.000.000

However, then users HAVE to put in the zeros, and don't like that much.

Here is what I would do:

I would use a input mask of:

999.999.999.999;0

the above means that ONLY 1 digit per group is required...the ";0" at the
end means the string will store the "." in the actual field.

The mask above will let a user go:

5.5.5.5

As the user types in the . (dot), the curosr will jump to the NEXT group.

Then, lets use some code AFTER user does above to "pad" with zeros...

So, AFTER access done it job,, lets use the after update event of the
contorl, and go:

Public Sub Text7_AfterUpdate()

Dim vList As Variant
Dim strResult As String

vList = Split(Me.Text7, ".")
For Each t In vList
If strResult <> "" Then strResult = strResult & "."
strResult = strResult & Format(t, "000")
Next
Me.Text7 = strResult

End Sub

The above will simply take the users input and pad it with zeros. I think
this is better then since you ALWASYS wll force a consistant format and that
will faciclite seaching, or printing this out in reprots.....

Note that we can't use the before update event since we can't change values
there.
 
P

Piet Linden

laziest/easiest way I can think of is to enter the 4 octets into
separate text fields and validate them individually ... they all have
to be between 0 and 255.
 

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