所以我有这个代码应该检查字符串中的某种类型的文本。如果字符串包含文本,则它将播放.wav文件。通过程序中的按钮单击执行代码。问题是,如果代码存在于字符串中并且我单击按钮,则第一次单击.wav文件时不会播放。但它是第二次点击它播放。这是相关的代码。
Dim htmlsource As String = ""
htmlsource = WebControl2.ExecuteJavascriptWithResult("document.documentElement.outerHTML") 'Takes HTML code using javascript
RichTextBox1.Text = htmlsource.ToString()
'-----------------------------------
'---------------text to look for----------------
Dim TradeOffer1 As String = "<span class=""notification"">"
Dim TradeCount As Integer = 0
Dim TradeOffer2 As String = " new offers</span>"
'-----------------------------------
'-While loop that searches for text-
While runloop = True
If htmlsource.Contains(String.Concat(TradeOffer1, TradeCount, TradeOffer2)) Then
My.Computer.Audio.Play("C:\Users\Thomas\pling.wav")
runloop = False
Else
TradeCount = TradeCount + 1
End If
If TradeCount = 6 Then
runloop = False
End If
End While
runloop = True
TradeCount = 0