如果listBox为空,如何停止应用程序? [英] How stop a app if listBox is empty?

查看:107
本文介绍了如果listBox为空,如何停止应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有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?

推荐答案

您是否只想浏览非空白的URL,对吗?
Do you want to navigate only non-blank URLs, right?
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
------------------------------

OP写道:

但是,我想在列表完成后停止计时器,例如,当网络浏览器已经存在时,我在列表框中输入了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

使用计时器的启动和停止 [

Use Timer.Stop Method[^]

Simple example here Timer Start and Stop[^]

EDIT2
-------------------------------

OP写道:

感谢您的帮助,但是我还有其他问题,我还有其他带有代理的列表框,我想在最后一次停止浏览器时使用了代理,您能帮我吗?

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为空,如何停止应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆