不知道这样是不是可以满足你的要求:
假设你输入的数字是InputNum
Dim sTemp() As String
If IsNumeric(Replace(InputNum, "-")) Then
sTemp = Split(InputNum, "-")
If UBound(sTemp) <> 1 Then '不是由一个"-"分隔的数字串
MsgBox "输入格式错误"
Else
If Len(sTemp(0)) <> 6 Then '"-"前数字位数不是6位
MsgBox "输入格式错误"
Else
If Len(sTemp(1)) <> 2 Then '"-"后数字位数不是2位
MsgBox "输入格式错误"
End If
End If
End If
Else
MsgBox "输入不全是数字"
End If