Private IsFocus As Boolean
Private Const XanhNhat = &HFF0000, XanhDam = &H800000
Private DonHang As String, DonVi As String, KhachHang As String, SoLuong As String
'*******************************************************************************************
Private Sub UserForm_Initialize()
DonHang = ChrW(272) & ChrW(417) & "n hàng"
DonVi = ChrW(272) & ChrW(417) & "n v" & ChrW(7883) & " tính"
KhachHang = "Khách hàng"
SoLuong = "S" & ChrW(7889) & " l" & ChrW(432) & ChrW(7907) & "ng"
Dim i As Byte
With ComboBox1
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
For i = 1 To 20
.AddItem "Hoàng Tr" & ChrW(7885) & "ng Ngh" & ChrW(297) & "a " & i
Next
End With
End Sub
'*******************************************************************************************
Private Sub ComboBox1_Enter()
IsFocus = False
End Sub
Private Sub ComboBox1_Change()
With ComboBox1
If .ForeColor <> XanhNhat Then
.Font.Italic = False
.ForeColor = XanhNhat
End If
End With
End Sub
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
With ComboBox1
If .Text = DonHang Then .Text = ""
End With
End Sub
Private Sub ComboBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With ComboBox1
If .Text = DonHang Then
.Text = ""
.Font.Italic = False
.ForeColor = XanhNhat
Else
If IsFocus = False Then
.SelStart = 0
.SelLength = Len(.Text)
End If
End If
End With
IsFocus = True
End Sub
Private Sub ComboBox1_DropButtonClick()
With ComboBox1
If .ForeColor <> XanhNhat Then
.Font.Italic = False
.ForeColor = XanhNhat
End If
End With
End Sub
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With ComboBox1
If .Text = "" Then
.Text = DonHang
.Font.Italic = True
.ForeColor = XanhDam
End If
End With
End Sub
'*******************************************************************************************