问题描述
我有一个带有URL的列表框,用于在Web浏览器中导航,如果列表框为空,我想停止应用程序或计时器:
我想停止此计时器或在blogurl.Text为空时关闭所有应用程序:
I have a listbox with URLs for navigate in a webbrowser, I want to stop the application or the timer if the listbox is empty :
I want to stop this timer or close all app when blogurl.Text is empty:
<pre lang="vb">Private Sub blognavegacion_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blognavegacion.Tick
WebBrowser1.Navigate(blogurl.Text)
End Sub</pre>
您能帮我吗?
Can you help me?
推荐答案
Private Sub blognavegacion_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blognavegacion.Tick
If Not blogurl.Text = "" then
WebBrowser1.Navigate(blogurl.Text)
End If
End Sub
或
Or
Private Sub blognavegacion_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blognavegacion.Tick
If blogurl.Text <> "" then
WebBrowser1.Navigate(blogurl.Text)
End If
End Sub
您也可以使用
Also you may use
If listBox.SelectedIndex = -1 then 'indicates nothing was selected
或
or
If listBox.SelectedItem Is Nothing Then
End If
编辑
------------------------------
EDIT
------------------------------
但是,我想在列表完成后停止计时器,例如,当网络浏览器已经存在时,我在列表框中输入了5个url访问了所有我想停止计时器的URL.对不起,我的英语不好
Thanks but I want to stop the timer when the list are finished, example I put 5 url in the listbox ,when the webbrowser already visited all url I want just to stop the timer.Sorry for my bad english
使用 [ ^ ]
这里的简单示例计时器的启动和停止 [ ^ ]
EDIT2
-------------------------------
Use Timer.Stop Method[^]
Simple example here Timer Start and Stop[^]
EDIT2
-------------------------------
感谢您的帮助,但是我还有其他问题,我还有其他带有代理的列表框,我想在最后一次停止浏览器时使用了代理,您能帮我吗?
Thanks you are very helpfull but I have other problem, I have other listbox with proxy and I want to stop the webbrowser when the last proxy was used, can you help me?
使用 [ ^ ]方法
这篇关于如果listBox为空,如何停止应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!