Hi,
I want add text in Listbox row based from item_code compare between two listboxes.
I put this code in celltextpaint
dim gg as integer
for gg=0 to ListPromo.Listcount -1
If me.cell(row,1)=ListPromo.cell(gg,0) then
me.cell(row,2)=me.cell(row,2)+"(PR)"
end if
next
its work, but print the additional text repeatedly.
how to get the result Just Listbox’s row’s text + “(PR)” in every rows which is has the same item_code
any helps ?
thanks
Arief
Hi,
still does not work,
I have change the code, but still print the (PR) repeatedly
dim o as Integer
for o=0 to Listbox1.Listcount -1
dim gg as integer
for gg=0 to ListPromo.Listcount -1
If Listbox1.cell(o,1)=ListPromo.cell(gg,0) then
Listbox1.cell(o,2)= Listbox1.cell(o,2)+"(PR)"
end if
next
next
where I should put this code in listbox’s event, the text result also looks ugly.
thanks
arief
I assume listbox and listpromo are of the same length?
dim gg as integer
for gg=0 to ListPromo.Listcount -1
If me.cell(gg,1)=ListPromo.cell(gg,0) then
me.cell(gg,2)=me.cell(gg,2)+"(PR)"
end if
next
if they are not the same length then:
For gg As Integer = 0 To Listbox1.ListCount - 1 'check all rows
For promo As Integer = 0 To ListPromo.ListCount - 1 'check all promos against this row
If Listbox1.Cell(gg, 1) = ListPromo.Cell(promo, 0) Then
Listbox1.Cell(gg, 2) = Listbox1.Cell(gg, 2) + "(PR)"
Exit For 'exit the check down the promo list because we've found the promo for this row
End If
Next
Next
PS. You could use a while for the internal promo loop but this method will be easier to understand
Where are-you added one or more Rows ?
(and why using the .CellTextPaint Event ?)
Hi,
I added rows from a textfield based from comparing code between two listboxes and its work.
I am putting in celltextpaint event, just want to give a mark that the rows in a listbox has passed the process.
yes, i will try to put the code in a method, and call afterwards.
thanks
arief
Oh I missed that you’re putting this in a paint even, don’t put this in a paint event
assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint, assigning a value to cell will update the cell and cause a paint
repeat…
I was thinking his ListBox was without Row