Không Đượ́c Bạn Ơi,Cái Code Của Mình Nó Khác Của Bạn,mìmh Đưa Lên Bạn Sửa Cho Mình Nha.
1. 33 = 16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32
2. 47 = 33-45-46
Code:
Private Sub CommandButton1_Click()
On Error GoTo loi
Me.Navi1 = Me.Navi1 - 1
Exit Sub
loi:
MsgBox "KhamHa: STop"
End Sub
Private Sub CommandButton2_Click()
On Error GoTo loi
Me.Navi1 = Me.Navi1 + 1
Exit Sub
loi:
MsgBox "KhamHa: STop"
End Sub
Private Sub CommandButton3_Click()
Me.dg = Me.Navi1.Max + 1
Me.CDblLThi.SetFocus
sua
End Sub
Private Sub CommandButton4_Click()
HS.Rows(Val(Me.dg)).EntireRow.Delete
Me.Navi1 = 5
Me.Navi1.Max = Me.Navi1.Max - 1
setsott
End Sub
Sub setsott()
Dim cl As Range
For Each cl In HS.Range("A5:A" & HS.[b65536].End(xlUp).Row)
cl = Val(cl.Offset(-1)) + 1
Next
End Sub
Private Sub CommandButton5_Click()
Dim kt
kt = MsgBox("KhamHa
eLete", vbOKCancel, "SaMoay Tax")
If kt = 1 Then HS.Rows(Me.dg).EntireRow.Delete
If Me.Navi1.Max > 1 Then
Me.Navi1.Max = Me.Navi1.Max - 1
Else
Me.Navi1.Max = 1
End If
End Sub
Private Sub CommandButtoncancel_Click()
Me.dg = Me.Navi1
loaddata
xem
End Sub
Private Sub CommandButtonOK_Click()
Dim i As Long, ctr As Control
Dim ch, ch1, tb
ch1 = "TextLThi;TextLVThi;TextLHKDPy;TextLPCTua;TextLTTam;TextBTho;TextXu;TextTJu;LHPy;PSMop;KNTLKit;HCMop;LNMACon;PPACon;NTy;BKhuan;NDuon;MMau;KXau;PPhuan;MKPhom;XXay;TSut;STem;OTTho;TNThang;TNiem03;B LCan03;TNTBACon;PMCACon;PMUUn;LHUUn;LNhot;ATB;CNSNSKha;KSNNho;HNNDuon;KXPLit;MKNOc;MKUUn;VTKSong;LMLec;BCNSKha;BSKMHot;ACTHac;ACTKMop;ACMTChing;CNNPTNSu;TBHNKhong;LThi2;LVThi2"
tb = Split(ch1, ";")
For i = 0 To UBound(tb) - 1
If Me.Controls(tb(i)) = "" Then
MsgBox " Kiem tra: " & tb(i), , "KhamHa KeoTaven"
Me.Controls(tb(i)).SetFocus
Exit Sub
End If
Next
If Not IsNumeric(Me.TextLThi) Then
MsgBox "LecThi", , "KhamHa KeoTaven"
Me.TextLVThi.SetFocus
Exit Sub
End If
'Phan nhap
i = Val(Me.dg)
With HS
.Cells(i, 2) = Me.TextLThi
.Cells(i, 3) = Me.TextLVThi
.Cells(i, 4) = Me.TextLHKDPy
.Cells(i, 5) = Me.TextLPCTua
.Cells(i, 6) = Me.TextLTTam
.Cells(i, 7) = Me.TextBTho
.Cells(i, 8) = Me.TextXu
.Cells(i, 9) = Me.TextTJu
.Cells(i, 10) = Me.ComboLHPy
.Cells(i, 11) = Me.ComboPSMop
.Cells(i, 12) = Me.ComboKNTLKit
.Cells(i, 13) = Me.ComboHCMop
.Cells(i, 14) = Me.TextLNMACon
.Cells(i, 15) = Me.TextPPACon
.Cells(i, 16) = Me.TextNTy
.Cells(i, 17) = Me.TextBKhuan
.Cells(i, 18) = Me.TextNDuon
.Cells(i, 19) = Me.TextMMau
.Cells(i, 20) = Me.TextKXau
.Cells(i, 21) = Me.TextPPhuan
.Cells(i, 22) = Me.TextMKPhom
.Cells(i, 23) = Me.TextXXay
.Cells(i, 24) = Me.TextTSut
.Cells(i, 25) = Me.TextSTem
.Cells(i, 26) = Me.TextOTTho
.Cells(i, 27) = Me.TextTNThang
.Cells(i, 28) = Me.TextTNiem03
.Cells(i, 39) = Me.TextBLCan03
.Cells(i, 30) = Me.TextTNTBACon
.Cells(i, 31) = Me.TextPMCACon
.Cells(i, 32) = Me.TextPMUUn
.Cells(i, 33) = Me.TextLNhot
.Cells(i, 34) = Me.ComboATB
.Cells(i, 35) = Me.TextCNSNSKha
.Cells(i, 36) = Me.TextKSNNho
.Cells(i, 37) = Me.TextHNNDuon
.Cells(i, 38) = Me.TextKXPLit
.Cells(i, 39) = Me.TextMKNOc
.Cells(i, 40) = Me.TextMKUUn
.Cells(i, 41) = Me.TextVTKSong
.Cells(i, 42) = Me.TextLMLec
.Cells(i, 43) = Me.TextBCNSKha
.Cells(i, 44) = Me.TextBSKMHot
.Cells(i, 45) = Me.TextACTHac
.Cells(i, 46) = Me.TextACTKMop
.Cells(i, 47) = Me.TextACMTChing
.Cells(i, 48) = Me.TextCNNPTNSu
.Cells(i, 49) = Me.ComboTBHNKhong
.Cells(i, 50) = Me.TextLThi2
.Cells(i, 51) = Me.TextLVThi2
End With
If Me.dg > Me.Navi1.Max Then Me.Navi1.Max = Me.dg
setsott
xem
End Sub
Private Sub CommandButtonSua_Click()
sua
End Sub
Private Sub dg_Change()
If Me.dg < 5 Then Me.dg = 5
loaddata
End Sub
Private Sub Navi1_Change()
Me.dg = Me.Navi1
End Sub
Private Sub UserForm_Initialize()
With Me
.Navi1.Min = 5
.Navi1.Max = HS.[b65536].End(xlUp).Row
.Navi1.Value = 5
End With
xem
End Sub
Sub loaddata()
Dim i
i = Val(Me.dg)
With HS
Me.TextLThi = .Cells(i, 2)
Me.TextLVThi = .Cells(i, 3)
Me.TextLHKDPy = .Cells(i, 4)
Me.TextLPCTua = .Cells(i, 5)
Me.TextLTTam = .Cells(i, 6)
Me.TextBTho = .Cells(i, 7)
Me.TextXu = .Cells(i, 8)
Me.TextTJu = .Cells(i, 9)
Me.ComboLHPy = .Cells(i, 10)
Me.ComboPSMop = .Cells(i, 11)
Me.ComboKNTLKit = .Cells(i, 12)
Me.ComboHCMop = .Cells(i, 13)
Me.TextLNMACon = .Cells(i, 14)
Me.TextPPACon = .Cells(i, 15)
Me.TextNTy = .Cells(i, 16)
Me.TextBKhuan = .Cells(i, 17)
Me.TextNDuon = .Cells(i, 18)
Me.TextMMau = .Cells(i, 19)
Me.TextKXau = .Cells(i, 20)
Me.TextPPhuan = .Cells(i, 21)
Me.TextMKPhom = .Cells(i, 22)
Me.TextXXay = .Cells(i, 23)
Me.TextTSut = .Cells(i, 24)
Me.TextSTem = .Cells(i, 25)
Me.TextOTTho = .Cells(i, 26)
Me.TextTNThang = .Cells(i, 27)
Me.TextTNiem03 = .Cells(i, 28)
Me.TextBLCan03 = .Cells(i, 29)
Me.TextTNTBACon = .Cells(i, 30)
Me.TextPMCACon = .Cells(i, 31)
Me.TextPMUUn = .Cells(i, 32)
Me.TextLNhot = .Cells(i, 33)
Me.ComboATB = .Cells(i, 34)
Me.TextCNSNSKha = .Cells(i, 35)
Me.TextKSNNho = .Cells(i, 36)
Me.TextHNNDuon = .Cells(i, 37)
Me.TextKXPLit = .Cells(i, 38)
Me.TextMKNOc = .Cells(i, 39)
Me.TextMKUUn = .Cells(i, 40)
Me.TextVTKSong = .Cells(i, 41)
Me.TextLMLec = .Cells(i, 42)
Me.TextBCNSKha = .Cells(i, 43)
Me.TextBSKMHot = .Cells(i, 44)
Me.TextACTHac = .Cells(i, 45)
Me.TextACTKMop = .Cells(i, 46)
Me.TextACMTChing = .Cells(i, 47)
Me.TextCNNPTNSu = .Cells(i, 48)
Me.ComboTBHNKhong = .Cells(i, 49)
Me.TextLThi2 = .Cells(i, 50)
Me.TextLVThi2 = .Cells(i, 51)
End With
End Sub
Sub xem()
With Me
.CommandButton1.Visible = True
.CommandButton2.Visible = True
.CommandButton3.Visible = True
.CommandButton5.Visible = True
.CommandButtonSua.Visible = True
.Navi1.Visible = True
.CommandButtoncancel.Visible = False
.CommandButtonOK.Visible = False
End With
End Sub
Sub sua()
With Me
.CommandButton1.Visible = False
.CommandButton2.Visible = False
.CommandButton3.Visible = False
.CommandButton5.Visible = False
.CommandButtonSua.Visible = False
.Navi1.Visible = False
.CommandButtoncancel.Visible = True
.CommandButtonOK.Visible = True
End With
End Sub