Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

General: Displaying IP Addresses by using an Input mask

Author(s)
Matthias Kaskel

To display IP Addresses in a text box, we can use an Input mask and few lines of code in the control's KeyDown and KeyUp events.

Input Mask:  099\.099\.099\.099;0;_

'   ***** Code Start ******
' This code was originally written by Matthias Kaskel.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Matthias Kaskel
'
Private Const vbKeyPoint As Integer = 190

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyPoint Or KeyCode = vbKeySpace Then
        If Text0.SelLength = 1 And Text0.SelStart < 12 Then
            Text0.SelStart = ((Text0.SelStart \ 4) + 1) * 4
        End If
        KeyCode = 0
    End If
End Sub

Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyPoint Or KeyCode = vbKeySpace Then
        KeyCode = 0
    End If
End Sub
'   ***** Code End ******

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer