这里是#039;如果输入的值大于12,它将提示您将英寸转换为英尺
- Private Sub txtLengthIn_Change()
- Dim vbResult As Long
- If txtLengthIn.Value >= 12 Then
- vbResult = MsgBox("Since you're attempting to enter a value GREATER than 12, would you like to convert it to FEET?", vbQuestion + vbYesNo, "Way to go!")
- If vbResult = vbYes Then
- MsgBox "Converted value = " & txtLengthIn / 12
- ElseIf vbResult = vbNo Then
- MsgBox "Start over!"
- txtLengthIn.Text = "0"
- txtLengthIn.SelStart = 0
- txtLengthIn.SelLength = txtLengthIn.TextLength
- End If
- End If
- End Sub
这将允许您在数字中添加句点(如果您不使用整英寸)
- Private Sub txtLengthIn_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
- If InStr(1, txtLengthIn.Text, ".") > 0 And KeyAscii = Asc(".") Then
- KeyAscii = 0
- Exit Sub
- End If
- Select Case KeyAscii
- Case Asc("0") To Asc("9"), Asc(".")
- Case Else
- KeyAscii = 0
- End Select
- End Sub
这只是你可能想考虑的其他事情。 |