?? mxtool.bas
字號:
Attribute VB_Name = "Mxtool"
'************************************************************
' Mxtool.bas
' -- Process PComm Lib function return value
'
'
''1999/4/2 TOM Modified
'************************************************************
Option Explicit
Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Public Const LANG_NEUTRAL = &H0
Public Const SUBLANG_DEFAULT = &H1
Declare Function GetLastError Lib "kernel32" () As Long
Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" _
(ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, _
ByVal dwLanguageId As Long, ByVal lpBuffer As String, _
ByVal nSize As Long, Arguments As Long) As Long
Public Sub ShowSysErr(title As String, syserr As Long)
Dim lpMsgBuf As String * 80
Dim lang As Integer
'lang = {MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) }
lang = SUBLANG_DEFAULT * 2 ^ 10 + LANG_NEUTRAL
Call FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, _
0, syserr, lang, lpMsgBuf, 80, 0)
Call MsgBox(lpMsgBuf, vbOKOnly Or vbExclamation, title)
End Sub
Public Sub MxShowError(title As String, errcode As Long, syserr As Long)
Dim buf As String
If errcode <> SIO_WIN32FAIL Then
Select Case errcode
Case SIO_BADPORT
buf = "通訊埠錯誤或未開啟"
Case SIO_OUTCONTROL:
buf = "未支援此功能"
Case SIO_NODATA:
buf = "未有資料被讀取"
Case SIO_OPENFAIL:
buf = "開啟錯誤"
Case SIO_RTS_BY_HW:
buf = "啟動硬體流量控制時不可控制RTS狀態"
Case SIO_BADPARM:
buf = "參數錯誤"
Case SIO_BOARDNOTSUPPORT:
buf = "介面未支援此函數"
Case SIO_ABORT_WRITE:
buf = "使用者中斷寫出動作"
Case SIO_WRITETIMEOUT:
buf = "輸出逾時"
Case Else
buf = "不可預測的錯誤:" & errcode
End Select
Call MsgBox(buf, vbOKOnly Or vbExclamation, title)
Else '系統錯誤的訊息
Call ShowSysErr(title, syserr)
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -