如何检查变量值是否 vb.net 增加?



嗨,我有列表视图和标签,标签显示列表视图中有多少项目 我想要如果标签增加将显示味精盒 * 可能会增加很多,例如 100 或 1 无论什么 * 如果值增加,它将只执行一个命令 * 如果值增加,则必须随时执行 msgbox 我很抱歉我的语言不好 谢谢

代码 :

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

在函数的顶部执行

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,那么您已经解决了您的一个问题(这是真的(。

最新更新