Prevent multiple MsgBoxs?

I have a Timer which fires every 3 seconds, and compares 2 columns of each row in my ListBox, to 2 textfields.
If a match is found, a unique MsgBox pops up.

The code below works fine BUT, every three seconds the same MsgBox is repeated.
I somehow need to allow the MsgBox to pop up only once for each row checked.

So, as an example:
Start at row1, compare columns 2 and 3 to the two TextFields, and if a match - Show the MsgBox Only Once.
Move on to Row2, compare columns 2 and 3 to the two TextFields, and if a match - Show the MsgBox Only Once.
Move on to Row3 etc. etc. etc.

for iRow As Integer = Window1.lb_Test.ListCount - 1 DownTo 0 if TextField1.Text =Window1.lb_Test.Cell(iRow,2) and Textfield2.Text= Window1.lb_Test.Cell(iRow,3) Then MsgBox("REMINDER: " + Window1.lb_Test.Cell(iRow,1)) end if next

For iRow As Integer = Window1.lb_Test.ListCount - 1 DownTo 0 If Window1.lb_Test.RowTag(iRow) = Nil Then If TextField1.Text = Window1.lb_Test.Cell(iRow, 2) And Textfield2.Text = Window1.lb_Test.Cell(iRow, 3) Then MsgBox("REMINDER: " + Window1.lb_Test.Cell(iRow, 1)) Window1.lb_Test.RowTag(iRow) = True End End Next

turn the timer off just prior to showing the MSGBOX, and turn it back on after the box has been dismissed.

Thanks guys.
Another problem solved due to the kindness of the members on here :slight_smile:

Just found a slight problem with your last solution:

If the user creates another row in the Listbox, the MsgBox re-displays?
I can’t seem to find a solution, whereby some kind of variable is attached to one particular row permanently - even if the Listbox rows change :frowning:

Would the RowTag or a zero-width column work?

Andrew, I tried the row tag, but as explained, if a new row in the listbox is created before the minute is up, the row tag becomes invalid and the MsgBox re-appears.

All of the columns already contain data, so Im not sure what you mean?


RowTag IS attached to the row permanently, even if the listbox rows change. How are you adding the new row? Inserting a row in the listbox will not affect the RowTag of existing rows. Now if you’re reloading the entire listbox to add a new row, then you would have a problem. In that case, you should add a column in the database to indicate that the reminder has been seen.

The user opens the “add new reminder window”, enters the time, date and description and the clicks on the save button which writes the values to a database.

The ListBox is then refreshed with the new updated database content.

I have added a 6th column (Read) to my database and also modified the code, to that below:

for iRow As Integer = Window1.lb_boxes.ListCount - 1 DownTo 0 If Window1.lb_boxes.Cell(iRow,6) <> "IsRead" Then if combinedFullTime =Window1.lb_boxes.Cell(iRow,2) and combinedFullDate= Window1.lb_boxes.Cell(iRow,3) Then Window1.lb_boxes.Cell(iRow,6) = "IsRead" MsgBox("REMINDER : " + Window1.lb_boxes.Cell(iRow,1)) sql="Insert into Boxes (Read) Values ("IsRead")" db4.sqlexecute (sql) end if end if next

I am not too sure about the syntax of line 7, regarding the quote marks encasing IsRead

You should be Updating, not Inserting. I assume there is enough data in the listbox row to uniquely identify the row in the database.

sql = "Update Boxes set Read = ‘IsRead’ Where somecolumn = " + Window1.lb_boxes.Cell(iRow, ???)

Replace the question marks with the column that contains the row’s identifier.

Thanks Tim - worked like a charm!