Private Sub tinh_Click()
Dim t As Byte, td As Variant
td = Array("", "X'", "Y'", "Z'", "X", "Y", "Z")
For t = 1 To 6
With Me("txtb" & t)
If Trim(.Text) = "" Then
MsgBox "Hay nhap toa do " & td(t)
.SetFocus
Exit Sub
End If
End With
Next
[COLOR=#ff0000]''Code cua ban[/COLOR]
End Sub
Private Sub txtb1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim KA As String
KA = Chr(KeyAscii)
If Not IsNumeric(KA) Then
If KA <> "." And KA <> "," Then KeyAscii = 0
End If
End Sub
Nếu muốn chỉ nhập là số ở các textbox, tôi làm ví dụ 1 trường hợp cho bạn, tự bạn làm việc với các textbox còn lại:
Mã:Private Sub txtb1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim KA As String KA = Chr(KeyAscii) If Not IsNumeric(KA) Then If KA <> "." And KA <> "," Then KeyAscii = 0 End If End Sub
Private Sub CommandButton2_Click()
Dim a As Double
a = TextBox1 + 1
' Range("A1").Value = TextBox1
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim ch As String
ch = Chr(KeyAscii)
[B][COLOR=#0000ff]' neu khong la chu so[/COLOR][/B]
If Not IsNumeric(ch) Then
[B][COLOR=#0000ff]' neu la ky tu thap phan[/COLOR][/B]
If IsNumeric("1" & ch) Then
[B][COLOR=#0000ff]' neu da co ky tu thap phan[/COLOR][/B]
If InStr(1, TextBox1, ch) > 0 Then KeyAscii = 0
Else
[B][COLOR=#0000ff]' khong la ky tu chu so va khong la ky tu thap phan[/COLOR][/B]
KeyAscii = 0
End If
End If
End Sub
Tôi chẳng biết bạn nói gì nữa, bạn muốn gì thì nói rõ ràng một chút, tiết kiệm lời quá tôi chẳng biết bạn cần gi!Làm sao ngắt được lựa chọn option và textbox riêng. Khi tắt lựa chọn option nó không hiện lên lựa chọn textbox. Xem file đính kèm.
If opt1.Value = False And opt2.Value = False Then
MsgBox "Hay chon he toa do muon chuyen"
[COLOR=#ff0000][B] Exit Sub[/B][/COLOR]
End If