Как проверить, увеличивается ли значение переменной vb.net?
Привет, у меня есть listview и lable, lable показывает, сколько элементов в listview, которое я хочу, если lable увеличено, покажет msgbox *, может быть, это увеличится много, например, 100 или 1, что угодно *. Он выполнит команду только один, если значение увеличивается * оно должно выполняться в любое время, если значение увеличивается, извините за плохой язык спасибо
код:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim b As String = New WebClient().DownloadString(TextBox2.Text + "/Getinfo.php")
Dim mc As MatchCollection = Regex.Matches(b, "(\w+):")
For Each x As Match In mc
Dim infoName As String = x.Groups(1).Value
Try
Dim download As String = New WebClient().DownloadString(TextBox2.Text + "/sender/info/" & infoName & "/info.txt")
Dim f As String() = download.Split(":")
Dim ls As New ListViewItem
ls.Text = infoName
For Each _x As String In f
ls.SubItems.Add(_x)
Next
Dim hTable As Hashtable = New Hashtable()
Dim duplicateList As ArrayList = New ArrayList()
Dim itm As ListViewItem
For Each itm In ListView1.Items
If hTable.ContainsKey(itm.Text) Then 'duplicate
duplicateList.Add(itm)
Else
hTable.Add(itm.Text, String.Empty)
End If
Next
'remove duplicates
For Each itm In duplicateList
itm.Remove()
Next
ListView1.Items.Add(ls)
'here I want to excute the command if the value is increased but it's timer and the code will be execute every time
Catch
End Try
Next
End Sub
1 ответ
Решение
В верхней части вашей функции сделать
Dim oldlength = ListView1.Items.Count
Внизу сделать
If oldlength < ListView1.Items.Count Then
'here I want to excute the command if the value is increased
End If
Я уверен, что ваш MessageBox
на самом деле это не то, что вам нужно, а пример отладки, потому что вы думаете, что если сможете получить MessageBox в нужное время, вы решили одну из своих проблем (что верно).