Findหาข้อมูลให้ขึ้นในListbox แต่ข้อมูลขึ้นไม่ครบครับ
Posted: Thu Mar 08, 2018 6:17 pm
ผมมีข้อมูลสินค้าอยู่1000กว่ารายการ ต้องการทำform สำหรับแสดงรายละเอียดสินค้าและแสดงภาพ
ตอนนี้ ผมจะทำให้คำKeyword ที่ต้องการค้นหา พอกดปุ่มenter แล้วมีชื่อสินค้าที่ตรงหรือมีคำkeyword อยู่ในชื่อยาวๆ ขึ้นในListbox
ตามโค้ดที่ผมทำมา มีผลลัพท์คือบางคำก็เจอ บางคำก็ไม่เจอ บางคำเจอแต่ขึ้นแค่ตัวที่เจอตัวแรกครับ
ตอนนี้ ผมจะทำให้คำKeyword ที่ต้องการค้นหา พอกดปุ่มenter แล้วมีชื่อสินค้าที่ตรงหรือมีคำkeyword อยู่ในชื่อยาวๆ ขึ้นในListbox
ตามโค้ดที่ผมทำมา มีผลลัพท์คือบางคำก็เจอ บางคำก็ไม่เจอ บางคำเจอแต่ขึ้นแค่ตัวที่เจอตัวแรกครับ
Code: Select all
Private Sub btnSname_Click()
Dim intCount As Integer
Dim intType As Integer
Dim intList As Integer
Dim intTotal As Integer
Dim ws As Workbook
intList = 2
intItem = 2
For intType = 1 To 12
If Cells(1, intType).Value = cbbType.Text Then
Exit For
End If
Next
If txtKey.Text = "" Then
strValueMsg = MsgBox("Please Enter Keyword", 1, "Foodscan Application")
Else
For intCount = 2 To 1500
If Cells(intCount, intType).Value = Sheet2.Cells.Find(txtKey.Value, LookIn:=xlFormulas, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext) Then
test.AddItem (Sheet2.Cells(intCount, 4))
End If
Next
End If
End Sub