Visual Basic 事件处理程序

发布于 2024-12-21 04:16:28 字数 405 浏览 3 评论 0原文

我正在尝试学习 Visual Basic,并且正在学习我儿子在课堂上使用的一本教科书。每次我通过双击设计页面来创建事件处理程序时,自动填充的代码几乎与书中的代码相同,只是代码中省略了 byval 部分。有人可以向我解释为什么会发生这种情况吗?我提供了本书代码的示例以及我最终得到的代码:

Private Sub frmConversion_Load(sender AS System.Object, e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub frmConversion_Load(ByVal sender AS System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

I am trying to learn Visual Basic and am working through a text book that my son used for a class. Each time I create an event handler by double clicking on the design page, the code that automatically populates is almost identical to the code in the book, except the byval portion is omitted from the code. Can someone explain to me why this happens. I have included an example of the book code and the code I end up with below.

Private Sub frmConversion_Load(sender AS System.Object, e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub frmConversion_Load(ByVal sender AS System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光磨忆 2024-12-28 04:16:28

查看 Form.Load Event它以第二个示例的样式显示事件。
根据此 Microsoft.Connect 请求页面,早期版本的 Visual Studio 看起来像是这样放入 ByVal,但由于它是默认值,因此在 Visual Studio 2010 SP1 中被删除。您的问题的答案是书中的示例代码是使用旧版本的 Visual Studio 创建的。

Looking at the Form.Load Event in MSDN it shows the event in the style of your second example.
It looks like according to this Microsoft.Connect request page the earlier versions of Visual Studio put in the ByVal, but since it is the default it was removed in Visual Studio 2010 SP1. The answer to your question is the example code in the book was created with an older version of Visual Studio.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文