doancu
Thành viên mới
- Tham gia
- 20/1/11
- Bài viết
- 14
- Được thích
- 0
- Giới tính
- Nam
Mọi cho mình hỏi làm sao cộng dồn trong lisbox đc vậy, ai biết chỉ giúp mình với, mình có gửi file qua và chi tiết, nhờ anh em cộng đồng chỉ giúp mình với thanks!!!
Dim dongcuoi As Long
dongcuoi = Sheets("Xuat").Range("B" & Rows.Count).End(xlUp).Row + 1
TextBox_sct.Value = "CTX" & dongcuoi 'tu dong tim dong cuoi chu tu nhap so tu dong
'---------------------------------------------------------
Dim a As Long
a = lstDMsanpham.ListIndex
TextBox_MaSP.Value = lstDMsanpham.List(a, 1) 'in maSP len TextBox_MaSP
TextBox_TenSP.Value = lstDMsanpham.List(a, 2) 'in tenSP len TextBox
TextBox_gia.Value = Format(lstDMsanpham.List(a, 4), "#,##0") 'in maSP len TextBox_MaSP
'--------------------------------------------------------------
TextBox_sl.SetFocus
End Sub
Private Sub lstDMsanpham_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim a As Long, b As Long, c As Long, arr, i As Integer, ii As Integer
a = lstDMsanpham.ListIndex
'----------------------------doc du lieu trong lstDMsanpham roi gan vao 10 bien
c = ListBox2.ListCount
ReDim arr(1 To c + 1, 1 To 11)
If c Then
For i = 0 To c - 1
arr(i + 1, 1) = ListBox2.List(i, 0)
arr(i + 1, 2) = ListBox2.List(i, 1)
arr(i + 1, 3) = ListBox2.List(i, 2)
arr(i + 1, 4) = ListBox2.List(i, 3)
arr(i + 1, 5) = ListBox2.List(i, 4)
arr(i + 1, 6) = ListBox2.List(i, 5)
arr(i + 1, 7) = ListBox2.List(i, 6)
arr(i + 1, 8) = ListBox2.List(i, 7)
arr(i + 1, 9) = ListBox2.List(i, 8)
arr(i + 1, 10) = ListBox2.List(i, 9)
arr(i + 1, 11) = ListBox2.List(i, 10)
Next i
End If
'--------------------------------doc du lieu trong lstDMsanpham roi gan vao 10 bien
'--------------------------------gan du lieu vao listbox2 gom 10 cot khai bao du 10 cot
c = c + 1
'-----------------------------------------------
' For ii = 1 To c
'
' If arr(ii, 5) = TextBox_MaSP.Value Then
' arr(ii, 8) = arr(ii, 8) + 1 'SO LUONG
' Else
'-----------------------------------------------
arr(c, 1) = TextBox_sct.Value 'MA CHUNG TU NHAP
'-------------------------------------------------KIEM TRA KO BO TRONG
If TextBox_ngay.Value = "" Then
MsgBox "Ban chua nhap NGAY ?", vbCritical
TextBox_ngay.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
arr(c, 2) = TextBox_ngay.Value 'GHI NGAY THANG
End If
'-------------------------------------------------KIEM TRA KO BO TRONG
If ComboBox_MaKH.Value = "" Then
MsgBox "Ban chua CHON MA KHACH HANG ?", vbCritical
ComboBox_MaKH.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
arr(c, 3) = ComboBox_MaKH.Value 'MA NHA CUNG CAP
End If
'-------------------------------------------------
arr(c, 4) = TextBox_tenKH.Value 'TEN NHA CUNG CAP
arr(c, 5) = lstDMsanpham.List(a, 1) 'MA SAN PHAM
arr(c, 6) = lstDMsanpham.List(a, 2) 'TEN SAN PHAM
arr(c, 7) = lstDMsanpham.List(a, 3) 'DON VI TINH
'-------------------------------------------------KIEM TRA KO BO TRONG
If TextBox_sl.Value = 0 Then
MsgBox "Ban chua NHAP SO LUONG ?", vbCritical
TextBox_sl.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
If CLng(TextBox_sl.Value) > lstDMsanpham.List(a, 10) Then
MsgBox "So luong khong duoc Lon hon So luong trong KHO ?", vbCritical
TextBox_sl.SetFocus
Exit Sub
Else
'---------------------------------------
arr(c, 8) = TextBox_sl.Value 'SO LUONG
lstDMsanpham.List(a, 10) = lstDMsanpham.List(a, 10) - CLng(TextBox_sl.Value) '======= tru sl xuat con lai sl ton ========================
'---------------------------------------
End If
End If
'-------------------------------------------------
arr(c, 9) = Format(TextBox_gia.Value, "#,##0") 'DON GIA
arr(c, 10) = Format(TextBox_ThanhTien.Value, "#,##0") 'THANH TIEN
arr(c, 11) = TextBox_VAT.Value 'VAT
'-----------------------------------------------
ListBox2.List = arr
TextBox_Tongtien.Value = Format(arr(c, 10) + CLng(TextBox_Tongtien.Value), "#,##0") 'THANH TIEN
'--------------------------------gan du lieu vao listbox2 gom 10 cot khai bao du 10 cot
TextBox_sl.SetFocus
TextBox_sl.Value = 0
CommandButton_luu.Enabled = True
CommandButton_in.Enabled = False
Bài đã được tự động gộp:
Dim dongcuoi As Long
dongcuoi = Sheets("Xuat").Range("B" & Rows.Count).End(xlUp).Row + 1
TextBox_sct.Value = "CTX" & dongcuoi 'tu dong tim dong cuoi chu tu nhap so tu dong
'---------------------------------------------------------
Dim a As Long
a = lstDMsanpham.ListIndex
TextBox_MaSP.Value = lstDMsanpham.List(a, 1) 'in maSP len TextBox_MaSP
TextBox_TenSP.Value = lstDMsanpham.List(a, 2) 'in tenSP len TextBox
TextBox_gia.Value = Format(lstDMsanpham.List(a, 4), "#,##0") 'in maSP len TextBox_MaSP
'--------------------------------------------------------------
TextBox_sl.SetFocus
End Sub
Private Sub lstDMsanpham_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim a As Long, b As Long, c As Long, arr, i As Integer, ii As Integer
a = lstDMsanpham.ListIndex
'----------------------------doc du lieu trong lstDMsanpham roi gan vao 10 bien
c = ListBox2.ListCount
ReDim arr(1 To c + 1, 1 To 11)
If c Then
For i = 0 To c - 1
arr(i + 1, 1) = ListBox2.List(i, 0)
arr(i + 1, 2) = ListBox2.List(i, 1)
arr(i + 1, 3) = ListBox2.List(i, 2)
arr(i + 1, 4) = ListBox2.List(i, 3)
arr(i + 1, 5) = ListBox2.List(i, 4)
arr(i + 1, 6) = ListBox2.List(i, 5)
arr(i + 1, 7) = ListBox2.List(i, 6)
arr(i + 1, 8) = ListBox2.List(i, 7)
arr(i + 1, 9) = ListBox2.List(i, 8)
arr(i + 1, 10) = ListBox2.List(i, 9)
arr(i + 1, 11) = ListBox2.List(i, 10)
Next i
End If
'--------------------------------doc du lieu trong lstDMsanpham roi gan vao 10 bien
'--------------------------------gan du lieu vao listbox2 gom 10 cot khai bao du 10 cot
c = c + 1
'-----------------------------------------------
' For ii = 1 To c
'
' If arr(ii, 5) = TextBox_MaSP.Value Then
' arr(ii, 8) = arr(ii, 8) + 1 'SO LUONG
' Else
'-----------------------------------------------
arr(c, 1) = TextBox_sct.Value 'MA CHUNG TU NHAP
'-------------------------------------------------KIEM TRA KO BO TRONG
If TextBox_ngay.Value = "" Then
MsgBox "Ban chua nhap NGAY ?", vbCritical
TextBox_ngay.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
arr(c, 2) = TextBox_ngay.Value 'GHI NGAY THANG
End If
'-------------------------------------------------KIEM TRA KO BO TRONG
If ComboBox_MaKH.Value = "" Then
MsgBox "Ban chua CHON MA KHACH HANG ?", vbCritical
ComboBox_MaKH.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
arr(c, 3) = ComboBox_MaKH.Value 'MA NHA CUNG CAP
End If
'-------------------------------------------------
arr(c, 4) = TextBox_tenKH.Value 'TEN NHA CUNG CAP
arr(c, 5) = lstDMsanpham.List(a, 1) 'MA SAN PHAM
arr(c, 6) = lstDMsanpham.List(a, 2) 'TEN SAN PHAM
arr(c, 7) = lstDMsanpham.List(a, 3) 'DON VI TINH
'-------------------------------------------------KIEM TRA KO BO TRONG
If TextBox_sl.Value = 0 Then
MsgBox "Ban chua NHAP SO LUONG ?", vbCritical
TextBox_sl.SetFocus ' DUA CON CHUOC VE DUNG VI TRI vbCritical
Exit Sub
Else
If CLng(TextBox_sl.Value) > lstDMsanpham.List(a, 10) Then
MsgBox "So luong khong duoc Lon hon So luong trong KHO ?", vbCritical
TextBox_sl.SetFocus
Exit Sub
Else
'---------------------------------------
arr(c, 8) = TextBox_sl.Value 'SO LUONG
lstDMsanpham.List(a, 10) = lstDMsanpham.List(a, 10) - CLng(TextBox_sl.Value) '======= tru sl xuat con lai sl ton ========================
'---------------------------------------
End If
End If
'-------------------------------------------------
arr(c, 9) = Format(TextBox_gia.Value, "#,##0") 'DON GIA
arr(c, 10) = Format(TextBox_ThanhTien.Value, "#,##0") 'THANH TIEN
arr(c, 11) = TextBox_VAT.Value 'VAT
'-----------------------------------------------
ListBox2.List = arr
TextBox_Tongtien.Value = Format(arr(c, 10) + CLng(TextBox_Tongtien.Value), "#,##0") 'THANH TIEN
'--------------------------------gan du lieu vao listbox2 gom 10 cot khai bao du 10 cot
TextBox_sl.SetFocus
TextBox_sl.Value = 0
CommandButton_luu.Enabled = True
CommandButton_in.Enabled = False
File đính kèm
Lần chỉnh sửa cuối: