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;_
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
|