在我的用戶表單中我想MsgBox如果文本框不包含數字或空。 這是我的代碼,但在另一種情況下TextBox = ""
空MsgBox對我來說,所以我的問題是空的TextBox。VBA用戶窗體文本框只允許數字和空文本
Private Sub TB1_Change()
If TypeName(Me.TB1) = "TextBox" Then
With Me.ActiveControl
L12.Caption = Val(TB1.Text) * Val(TB2.Text)
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
End If
End With
End If
End Sub
什麼'MsgBox「對不起,只允許輸入數字,但是輸入'」&.Value&「'。」'寫入'''之間? –
對不起,我不明白的味精:) –
用我貼的代碼替換你的MsgBox代碼。運行你的代碼,並告訴我們當你的文本框爲空時MsgBox中的內容。 –