HandleError子程序示例
2015-12-15 22:24:33 来源: 评论:0 点击:
下列示例示范如何在捕捉错误时使用HandleError子程序。 Public Function GetDecimalSeparator() Dim intCountChar As Integer Dim lngHolder As Long Dim strDecChar As String On Error GoTo
下列示例示范如何在捕捉错误时使用HandleError子程序。
Public Function GetDecimalSeparator()
Dim intCountChar As Integer
Dim lngHolder As Long
Dim strDecChar As String
On Error GoTo ErrorHandler
'设定返回值的缓存
strDecChar = Space$(255)
'取得千位分隔符的十位分隔符和字符数量
lngHolder = GetLocaleInfoA(GetUserDefaultLCID(), LOCALE_SDECIMAL, strDecChar, Len(strDecChar) + 1)
'现在把返回值设为正好是十位分隔符。
GetDecimalSeparator = Left$(strDecChar, lngHolder - 1)
Exit Function
ErrorHandler:
HandleError
End Function