- UID
- 5244
- 积分
- 1648
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2002-11-22 09:00:05
|
显示全部楼层
你可以用VB6.0为R2000版本中所没有的VBA函数做一个库,使用时只要引用就可以了,相当于扩充了CAD中VBA的功能。
附上一些例子。
- [FONT=courier new]
- Public Enum VbTriState
- vbFalse = 0
- vbTrue = -1
- vbUseDefault = -2
- End Enum
- Public Enum VbCompareMethod
- vbBinaryCompare = 0
- vbDatabaseCompare = 2
- vbTextCompare = 1
- End Enum
- Public Function VBFilter(ByVal SourceArray As Variant, ByVal Match As String, Optional ByVal Include As Boolean = True, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare)
- VBFilter = ""
- On Error GoTo ErrTrap
- VBFilter = Filter(SourceArray, Match, Include, Compare)
- Exit Function
- ErrTrap:
- Debug.Print "VBFilter: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBFormatCurrency(ByVal Expression As Variant, Optional ByVal NumDigitsAfterDecimal As Long = -1, Optional ByVal IncludeLeadingDigit As VbTriState = vbUseDefault, Optional ByVal UseParensForNegativeNumbers As VbTriState = vbUseDefault, Optional ByVal GroupDigits As VbTriState = vbUseDefault) As String
- VBFormatCurrency = ""
- On Error GoTo ErrTrap
- VBFormatCurrency = FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits)
- Exit Function
- ErrTrap:
- Debug.Print "VBFormatCurrency: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBFormatDateTime(ByVal Expression As Variant, Optional ByVal NamedFormat As VbDateTimeFormat = vbGeneralDate) As String
- VBFormatDateTime = ""
- On Error GoTo ErrTrap
- VBFormatDateTime = FormatDateTime(Expression, NamedFormat)
- Exit Function
- ErrTrap:
- Debug.Print "VBFormatDateTime: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBFormatNumber(ByVal Expression As Variant, Optional ByVal NumDigitsAfterDecimal As Long = -1, Optional ByVal IncludeLeadingDigit As VbTriState = vbUseDefault, Optional ByVal UseParensForNegativeNumbers As VbTriState = vbUseDefault, Optional ByVal GroupDigits As VbTriState = vbUseDefault) As String
- VBFormatNumber = ""
- On Error GoTo ErrTrap
- VBFormatNumber = FormatNumber(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits)
- Exit Function
- ErrTrap:
- Debug.Print "VBFormatNumber: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBFormatPercent(ByVal Expression As Variant, Optional ByVal NumDigitsAfterDecimal As Long = -1, Optional ByVal IncludeLeadingDigit As VbTriState = vbUseDefault, Optional ByVal UseParensForNegativeNumbers As VbTriState = vbUseDefault, Optional ByVal GroupDigits As VbTriState = vbUseDefault) As String
- VBFormatPercent = ""
- On Error GoTo ErrTrap
- VBFormatPercent = FormatPercent(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits)
- Exit Function
- ErrTrap:
- Debug.Print "VBFormatPercent: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBInStrRev(ByVal StringCheck As String, StringMatch As String, Optional ByVal Start As Long = -1, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As Long
- VBInStrRev = ""
- On Error GoTo ErrTrap
- VBInStrRev = InStrRev(StringCheck, StringMatch, Start, Compare)
- Exit Function
- ErrTrap:
- Debug.Print "VBInStrRev: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBJoin(ByVal SourceArray As Variant, Optional ByVal Delimiter As Variant) As String
- VBJoin = ""
- On Error GoTo ErrTrap
- VBJoin = Join(SourceArray, Delimiter)
- Exit Function
- ErrTrap:
- Debug.Print "VBJoin: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBReplace(ByVal Expression As String, ByVal Find As String, ByVal ReplaceWith As String, Optional ByVal Start As Long = 1, Optional ByVal Count As Long = -1, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As String
- VBReplace = ""
- On Error GoTo ErrTrap
- VBReplace = Replace(Expression, Find, ReplaceWith, Start, Count, Compare)
- Exit Function
- ErrTrap:
- Debug.Print "VBReplace: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBRound(ByVal Number As Variant, Optional ByVal NumDigitsAfterDecimal As Long)
- VBRound = ""
- On Error GoTo ErrTrap
- VBRound = Round(Number, NumDigitsAfterDecimal)
- Exit Function
- ErrTrap:
- Debug.Print "VBRound: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- Public Function VBSplit(ByVal Expression As String, Optional ByVal Delimiter As Variant, Optional ByVal Limit As Long = -1, Optional ByVal Compare As VbCompareMethod = vbBinaryCompare) As Variant
- VBSplit = Empty
- On Error GoTo ErrTrap
- VBSplit = Split(Expression, Delimiter, Limit, Compare)
- Exit Function
- ErrTrap:
- Debug.Print "VBSplit: " & Err.Number & ", " & Err.Description
- On Error GoTo 0
- End Function
- [/FONT]
|
|