Chào mọi người,
mình có 1 file excel đã tạo form nhập số liệu ,nay cần tạo thêm listbox, làm mấy hôm vẩn bị lỗi, mong mọi người chỉ giúp cám ơn mọi người,,,
mình đã tạo 1 texbox và 1 listbox, mình cần đánh tên khách hoặc số Inv thì listbox sẽ hiện ra hết thông tin, đồng thời đưa dữ liệu từ ô ListBox sang TextBox .
mình đọc được 1 Web hướng dẫn làm theo những không hiện ra , mong mọi người chỉ giúp , xin cám ơn......
Code cho nút tìm kiếm:
mình có 1 file excel đã tạo form nhập số liệu ,nay cần tạo thêm listbox, làm mấy hôm vẩn bị lỗi, mong mọi người chỉ giúp cám ơn mọi người,,,
mình đã tạo 1 texbox và 1 listbox, mình cần đánh tên khách hoặc số Inv thì listbox sẽ hiện ra hết thông tin, đồng thời đưa dữ liệu từ ô ListBox sang TextBox .
mình đọc được 1 Web hướng dẫn làm theo những không hiện ra , mong mọi người chỉ giúp , xin cám ơn......
Code cho nút tìm kiếm:
Private Sub Userform_intialize() '// thiet lap form de tim kiem
Me.txtSearch.SetFocus
End Sub
Code đưa dữ liệu từ ô ListBox sang TextBoxPrivate Sub btnSearch_Click() '// tim kiem du lieu
On Error Resume Next
Me.ListBox1.Clear
Me.ListBox1.AddItem Sheet1.Cells(1, "A")
For B = 2 To 6
Me.ListBox1.List(ListBox1.ListCount - 1, B - 1) = Sheet1.Cells(1, B)
Next B
Me.ListBox1.Selected(0) = True
Dim i As Long
For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
For x = 1 To 6
a = Len(Me.txtSearch.Text)
If Left(Sheet1.Cells(i, x).Value, a) = Me.txtSearch.Text And Me.txtSearch.Text <> "" Then
Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
For c = 1 To 6
Me.ListBox1.List(ListBox1.ListCount - 1, c) = Sheet1.Cells(i, c + 1).Value
Next c
End If
Next x
Next i
End Sub
Private Sub ListBox1_Click()
On Error Resume Next
Me.txtMa.Text = ListBox1.List(ListBox1.ListIndex, 0)
Me.txtDate.Text = ListBox1.List(ListBox1.ListIndex, 1)
Me.txtTen.Text = ListBox1.List(ListBox1.ListIndex, 2)
Me.txtNgaysinh.Text = ListBox1.List(ListBox1.ListIndex, 3)
Me.txtNghenghiep.Text = ListBox1.List(ListBox1.ListIndex, 4)
Me.txtDiachi.Text = ListBox1.List(ListBox1.ListIndex, 5)
End Sub