Private Sub btg_nt_Click()
Call location
End Sub
Private Sub btg_d8_Click()
Call location
End Sub
Private Sub btg_k4_Click()
Call location
End Sub
Private Sub btg_bt_Click()
Call location
End Sub
Sub location()
If Me.btg_nt.Value = True Then
Me.txt_location.Value = "Nha Tre"
End If
If Me.btg_k4.Value = True Then
Me.txt_location.Value = "Khu 4"
End If
If Me.btg_d8.Value = True Then
Me.txt_location.Value = "D-8"
End If
If Me.btg_bt.Value = True Then
Me.txt_location.Value = "Biet Thu"
End If
If Me.btg_nt.Value = True Then
Me.btg_bt.Value = False
Me.btg_d8.Value = False
Me.btg_k4.Value = False
End If
If Me.btg_d8.Value = True Then
Me.btg_bt.Value = False
Me.btg_k4.Value = False
Me.btg_nt.Value = False
End If
If Me.btg_k4.Value = True Then
Me.btg_nt.Value = False
Me.btg_d8.Value = False
Me.btg_bt.Value = False
End If
If Me.btg_bt.Value = True Then
Me.btg_k4.Value = False
Me.btg_nt.Value = False
Me.btg_d8.Value = False
End If
End Sub
Private Sub btn_Them_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets(4)
If Me.txt_bs.Value = "Bien So" Then
MsgBox "Vui long Nhap Bien So Xe"
If Excel.WorksheetFunction.And(Me.btg_bt.Value = False, Me.btg_d8.Value = False, Me.btg_k4.Value = False, Me.btg_nt.Value = False) Then
MsgBox "VUI LONG CHON KHO LUU TRU"
End If
Exit Sub
End If
Dim lastrow As Double
lastrow = Excel.WorksheetFunction.CountA(ws.Range("B:B")) + 1
ws.Range("B" & lastrow + 1).Value = Me.txt_date.Value
ws.Range("C" & lastrow + 1).Value = Me.txt_bs.Value
ws.Range("D" & lastrow + 1).Value = Me.txt_location.Value
ws.Range("F" & lastrow + 1).Value = Me.txt_note.Value
Call Khoi_tao_xe
MsgBox "Nhap Thanh Cong"
End Sub
Private Sub txt_bs_Enter()
If Me.txt_bs.Value = "Bien So" Then
Me.txt_bs.Value = ""
Me.txt_bs.ForeColor = vbBlack
End If
End Sub
Private Sub txt_bs_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Me.txt_bs.Value = "" Then
Me.txt_bs.Value = "Bien So"
Me.txt_bs.ForeColor = RGB(191, 191, 191)
End If
End Sub
Private Sub txt_date_Enter()
If Me.txt_date.Value = Date Then
Me.txt_date.Value = ""
Me.txt_date.ForeColor = vbBlack
End If
End Sub
Private Sub txt_date_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Me.txt_date.Value = "" Then
Me.txt_date.Value = Date
Me.txt_date.ForeColor = RGB(191, 191, 191)
End If
End Sub
Private Sub txt_note_Enter()
If Me.txt_note.Value = "Ghi Chú" Then
Me.txt_note.Value = ""
Me.txt_note.ForeColor = vbBlack
End If
End Sub
Private Sub txt_note_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Me.txt_note.Value = "" Then
Me.txt_note.Value = ""
Me.txt_note.ForeColor = RGB(191, 191, 191)
End If
End Sub
Private Sub UserForm_Initialize()
Call Khoi_tao_xe
End Sub
Sub Khoi_tao_xe()
Me.txt_bs.Value = "Bien So"
Me.txt_date.Value = Date
Me.txt_note.Value = "Ghi Chú"
Me.txt_bs.ForeColor = RGB(191, 191, 191)
Me.txt_date.ForeColor = RGB(191, 191, 191)
Me.txt_note.ForeColor = RGB(191, 191, 191)
Me.btg_nt.Value = False
Me.btg_k4.Value = False
Me.btg_d8.Value = False
Me.btg_bt.Value = False
Me.txt_row_id.Value = ""
End Sub
mình đang làm như thế này. nhưng cảm thấy nó lòng vòng thật. các bác có cách nào rút gọn được không ạ