Dim isExit As Boolean
''===========================================================================================================================
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
isExit = True
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = 1
End Sub
''===========================================================================================================================
Private Sub ComboBox1_Enter()
isExit = True
End Sub
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
End Sub
Private Sub ComboBox1_Change()
TextBox1.Enabled = True
End Sub
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If ComboBox1 = "" Or Val(ComboBox1) = 0 Then Exit Sub
If isExit = False Then Exit Sub
If WorksheetFunction.CountIf(Range("MaSo"), ComboBox1) = 0 Then
MsgBox "Ban nhap chua dung!"
TextBox1.Enabled = False
With ComboBox1
.SetFocus: .SelStart = 0: .SelLength = Len(.Text)
End With
End If
End Sub
''===========================================================================================================================
Private Sub TextBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
isExit = True
End Sub
''===========================================================================================================================
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
isExit = False
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
'===========================================================================================================================