標題: 要如何強制驗證TextBox空白就停止 [打印本頁] 作者: Jared 時間: 2013-3-18 15:34 標題: 要如何強制驗證TextBox空白就停止
想請問各位大大
目前想將TextBox用驗證碼是否空白
如果空白就停止輸入
將畫面停格在輸入畫面
Dim A As Range
a1 = User.c1.Value
If a1 = "" Then MsgBox "第一欄不得空白": Exit Sub
If Application.CountBlank([U3:U99]) = 0 Then Range("U100") = a1: Exit Sub
For Each A In [U3:U99]
If A = "" Then
A.Value = a1
Exit For
End If
Next
Sub test()
Dim Ar, a1, a2, a3, a4,a5,i %
a1 = TextBox1
a2 = TextBox2
a3 = TextBox3
a4 = TextBox4
a5 = TextBox5
Ar = Array(a1, a2, a3,a4,a5)
If a1 <> "" And a2 <> "" And a3 <> "" And a4 <> "" And a5 <> "" Then
i = 1
Do Until Cells(i, 1) = ""
i = i + 1
Loop
Cells(i, 1).Resize(, 5) = Ar
Else
For i = 0 To 2
If Ar(i) = "" Then MsgBox "欄位" & i + 1 & "空白未填寫"
Next
End If
End Sub作者: Jared 時間: 2013-3-19 15:29