• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

VB.NET ErrObject.Number属性代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中Microsoft.VisualBasic.ErrObject.Number属性的典型用法代码示例。如果您正苦于以下问题:VB.NET ErrObject.Number属性的具体用法?VB.NET ErrObject.Number怎么用?VB.NET ErrObject.Number使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。



在下文中一共展示了ErrObject.Number属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: test

' Typical use of Number property.
Sub test()
  On Error GoTo out

  Dim x, y As Integer
  x = 1 / y   ' Create division by zero error.
  Exit Sub
out:
  MsgBox(Err.Number)
  MsgBox(Err.Description)
  ' Check for division by zero error.
  If Err.Number = 11 Then
      y = y + 1
  End If
  Resume Next
End Sub
开发者ID:VB.NET开发者,项目名称:Microsoft.VisualBasic,代码行数:16,代码来源:ErrObject.Number


示例2: Module1

Module Module1

    Const WidthErrorNumber As Integer = 1000
    Const WidthHelpOffset As Object = 100

    Sub Main()
        CallingProcedure()
    End Sub

    Sub TestWidth(ByVal width As Integer)
        If width > 1000 Then
            ' Replace HelpFile.hlp with the full path to an appropriate
            ' help file for the error. Notice that you add the error 
            ' number you want to use to the vbObjectError constant. 
            ' This assures that it will not conflict with a Visual
            ' Basic error.
            Err.Raise(vbObjectError + WidthErrorNumber, "ConsoleApplication1.Module1.TestWidth", 
                "Width must be less than 1000.", "HelpFile.hlp", WidthHelpOffset)
        End If
    End Sub

    Sub CallingProcedure()
        Try
            ' The error is raised in TestWidth.
            TestWidth(2000)
        Catch ex As Exception
            ' The Err object can access a number of pieces of
            ' information about the error.
            Console.WriteLine("Information available from Err object:")
            Console.WriteLine(Err.Number)
            Console.WriteLine(Err.Description)
            Console.WriteLine(Err.Source)
            Console.WriteLine(Err.HelpFile)
            Console.WriteLine(Err.HelpContext)
            Console.WriteLine(Err.GetException)

            Console.WriteLine(vbCrLf & "Information available from Exception object:")
            Console.WriteLine(ex.Message)
            Console.WriteLine(ex.ToString)

            Err.Clear()
        End Try
    End Sub
End Module
开发者ID:VB.NET开发者,项目名称:Microsoft.VisualBasic,代码行数:44,代码来源:ErrObject.Number

输出:

Information available from Err object:
-2147220504
Width must be less than 1000.
ConsoleApplication1.Module1.TestWidth
HelpFile.hlp
100
System.Exception: Width must be less than 1000.
at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object
Description, Object HelpFile, Object HelpContext)
at ConsoleApplication1.Module1.TestWidth(Int32 width) in C:\Users\example\App
Data\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 17
at ConsoleApplication1.Module1.CallingProcedure() in C:\Users\example\AppData
\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 25

Information available from Exception object:
Width must be less than 1000.
System.Exception: Width must be less than 1000.
at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object
Description, Object HelpFile, Object HelpContext)
at ConsoleApplication1.Module1.TestWidth(Int32 width) in C:\Users\example\App
Data\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 17
at ConsoleApplication1.Module1.CallingProcedure() in C:\Users\example\AppData
\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 25



注:本文中的Microsoft.VisualBasic.ErrObject.Number属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET ErrObject.Source属性代码示例发布时间:2022-05-26
下一篇:
VB.NET Collection.Count属性代码示例发布时间:2022-05-26
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap