【发布时间】:2014-11-29 19:36:31
【问题描述】:
我的程序运行良好,但是,如果没有互联网连接,它就会崩溃。(错误:blabla 停止工作)
我的程序 exe
Module module2
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://www.example.org")
Dim oza As Object
Sub main()
oza = CreateObject("InternetExplorer.Application")
oza.Navigate2("http://www.example.org", "", "", "")
End Sub
End Module
如何防止程序崩溃?
【问题讨论】:
-
抛出了异常,不是吗? - 见Handling and Throwing Exceptions
-
无法理解您的意思。
-
好吧,例如,如果
DownloadString抛出 WebException (因为它无法下载文件,因为互联网不可用)然后程序,它不会优雅地处理异常,将“异常”终止。请参阅第一条评论中的链接。