Sub Main() [英] Sub Main()

查看:111
本文介绍了Sub Main()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



好​​的,我有一个包含多种形式的VB2005 Beta 2项目。我将Form1设置为

我的启动表单。我想改变它以使modMain的Sub Main(下面列出

)成为启动文件。我该怎么做呢?如果我转到

应用程序属性并选择Windows应用程序类型

应用程序,我只能选择一个启动表单,而不是modMain。


阅读有关异常处理的内容,我正在努力开始使用它。


谢谢,


Thomas


公共模块modMain


Public Shared Sub Main()


AddHandler Application.ThreadException,AddressOf

Application_ThreadException


尝试

Application.Run(新Form1)

Catch ex As Exception

LogException(ex)

结束尝试


结束子


私有子Application_ThreadException( ByVal sender As Object,ByVal e

As System.Threading.ThreadExceptionEventArgs)


LogException(e.Exception)


End Sub


Private Sub LogException(ByVal ex As Exception)


''代码将错误写入一个sql数据库


结束子

结束模块


-

发布通过NewsDemon.com - 高级未经审查的新闻组服务

------->>>>>> http://www.NewsDemon.com<<< <<< ------

无限制访问,匿名帐户,未经审查的宽带访问


Ok, I have a VB2005 Beta 2 project with several forms. I have Form1 set as
my startup form. I want to change this to have Sub Main of modMain (listed
below) to be the startup file. How do I do this? If I go to the
application properties and choose an Application Type of Windows
Application, I can only chose a startup Form, not the modMain.

Been reading about exception handling and I am trying to get started on it.

Thanks,

Thomas

Public Module modMain

Public Shared Sub Main()

AddHandler Application.ThreadException, AddressOf
Application_ThreadException

Try
Application.Run(New Form1)
Catch ex As Exception
LogException(ex)
End Try

End Sub

Private Sub Application_ThreadException(ByVal sender As Object, ByVal e
As System.Threading.ThreadExceptionEventArgs)

LogException(e.Exception)

End Sub

Private Sub LogException(ByVal ex As Exception)

'' code that writes error to an sql database

End Sub
End Module

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

推荐答案

<第***** @ msala.net> schrieb:
<th*****@msala.net> schrieb:
好的,我有一个包含多种形式的VB2005 Beta 2项目。我将Form1设置为
我的启动表单。我想将此更改为modMain的子主页
(在下面列出
)作为启动文件。我该怎么做呢?如果我转到
应用程序属性并选择应用程序类型的Windows
应用程序,我只能选择一个启动表单,而不是modMain。


选择我的项目在解决方案资源管理器中 - > "申请表] - > [_]启用

应用程序框架。然后你可以选择Sub Main和Sub Main。来自Startup

对象:组合框。

AddHandler Application.ThreadException,AddressOf
Ok, I have a VB2005 Beta 2 project with several forms. I have Form1 set
as
my startup form. I want to change this to have Sub Main of modMain
(listed
below) to be the startup file. How do I do this? If I go to the
application properties and choose an Application Type of Windows
Application, I can only chose a startup Form, not the modMain.
Select "My Project" in the solution explorer -> "Application" -> [_] "Enable
application framework". Then you can select "Sub Main" from the "Startup
object:" combobox.
AddHandler Application.ThreadException, AddressOf



请注意VB 2005提供的应用程序事件可由
$处理b $ b点击查看应用程序事件... 我的项目按钮上的按钮

应用程序选项卡。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps。 org />

VB< URL:http://classicvb.org/petition/>



Note that VB 2005 provides application events, which can be handled by
clicking the "View Application Events..." button on "My Project"''s
"Application" tab.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>




感谢您的回答,但这与我在网上搜索所得到的答案相同。

我希望我在这里遗漏一些东西。我已经附上

作为屏幕截图。选择启动表格是我看到的所有,Sub Main未列出

下拉菜单。


谢谢,


Thomas

BM?*?


-

发表于NewsDemon.com - 高级未经审查的新闻组服务

------->>>>>> http://www.NewsDemon.com<<<<<<< ------

无限制访问,匿名帐户,未经审查的宽带访问

Thanks for the answer, but it is the same answer I have been getting from
all my web searching. I hope I am missing something here. I have attached
as screen shot. Select startup Form is all I see and Sub Main is not listed
in the dropdown.

Thanks,

Thomas
BM*

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access




我想我的新闻阅读器不允许我附加文件。


-

通过NewsDemon.com发布 - 高级未经审查的新闻组服务

-------> >>>>> http://www.NewsDemon.com<<<<<< ------

无限制访问,匿名帐户,未经审查的宽带接入

I guess my newsreader will not allow me to attach files.

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


这篇关于Sub Main()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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