|
-
Mar 31st, 2021, 05:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] ListBox items will be added infinitely
Let me make the long story short. A part of my application is a small "Active alarm monitoring" thing which works by comparing plenty of variables by set-points and if they are critical, out of range, etc. it sorts the corresponding parameter. Whole process will operate on a timer control. Therefore, adding an item [as an alarm] keeps repeating.
I'm looking for a way of programming to do same thing "once". Thanx everyone
-
Mar 31st, 2021, 05:44 PM
#2
Re: ListBox items will be added infinitely
Can you show us your code?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 31st, 2021, 06:32 PM
#3
Re: ListBox items will be added infinitely
Without your code it's not easy to give an answer, but it sounds as though...
If you set a Boolean variable whilst you're processing one alarm... And if you don't allow another to process whilst the boolean is set...
Maybe add any new alarms to a list of 'Do these when it's clear' you could also check that they're not duplicated before you process the next.
Poppa
Along with the sunshine there has to be a little rain sometime.
-
Mar 31st, 2021, 06:53 PM
#4
Re: ListBox items will be added infinitely
Code:
Public Class Form13
Private WithEvents tmr As New Timer With {.Interval = 1000}
Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tmr.Start()
End Sub
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
If ListBox1.FindStringExact("the item you're planning to add") = -1 Then ' doesn't contain
ListBox1.Items.Add("the item you're planning to add")
End If
End Sub
End Class
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 1st, 2021, 04:54 AM
#5
Thread Starter
Hyperactive Member
Re: ListBox items will be added infinitely
 Originally Posted by .paul.
Code:
Public Class Form13
Private WithEvents tmr As New Timer With {.Interval = 1000}
Private Sub Form13_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tmr.Start()
End Sub
Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick
If ListBox1.FindStringExact("the item you're planning to add") = -1 Then ' doesn't contain
ListBox1.Items.Add("the item you're planning to add")
End If
End Sub
End Class
Hey Paul! I wish you would add more description about your code however comments are clear and helpful. Thanks. I will consider your method but I'm thinking about another way to to do the same for example using Text1.Text TextChanged event which performs longer than timer's interval. .FindStringExact was dope tho ; )))))))
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|