📄 ip.frm
字号:
VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form Form1
Caption = "IP"
ClientHeight = 915
ClientLeft = 60
ClientTop = 345
ClientWidth = 2580
LinkTopic = "Form1"
ScaleHeight = 915
ScaleWidth = 2580
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "退出"
Height = 255
Left = 1560
TabIndex = 3
Top = 600
Width = 855
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 255
Left = 120
TabIndex = 2
Top = 600
Width = 855
End
Begin MSMask.MaskEdBox MaskEdBox1
Height = 375
Left = 840
TabIndex = 0
Top = 120
Width = 1575
_ExtentX = 2778
_ExtentY = 661
_Version = 393216
PromptInclude = 0 'False
AllowPrompt = -1 'True
AutoTab = -1 'True
HideSelection = 0 'False
MaxLength = 15
Mask = "###.###.###.###"
PromptChar = "#"
End
Begin VB.Label Label1
Caption = "IP:"
Height = 255
Left = 120
TabIndex = 1
Top = 240
Width = 375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 判断用户输入的IP地址是否合理
Private Sub Command1_Click()
Dim i1 As String
Dim j1 As String
Dim j2 As String
Dim j3 As String
Dim j4 As String
'获得MaskEdBox1中输入的字符
i1 = MaskEdBox1.Text
j1 = Mid$(i1, 1, 3)
j2 = Mid$(i1, 4, 3)
j3 = Mid$(i1, 7, 3)
j4 = Mid$(i1, 10, 3)
'判断IP地址输入是否有误
If (Val(j1) > 255) Or (Val(j2) > 255) Or (Val(j3) > 255) _
Or (Val(j4) > 255) Then
MsgBox "IP地址输入有误"
End If
End Sub
'退出程序
Private Sub Command2_Click()
End
End Sub
'MaskEdBox控件的无效输入时处理代码
Private Sub MaskEdBox1_ValidationError(InvalidText As String, StartPosition As Integer)
MsgBox "只能输入数字", vbExclamation, "IP"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -