因为工作需要,我必须解决一个用VBA开发的软件的一个小问题。
这就是,这个VBA引用的VB For App版本很低,没有Split这些函数,我想用C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL中的Split函数,但是怎么都没有办法声明成功。我的模块级别的声明是这样的
Declare Function SplitA Lib "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL" ( _
ByVal Expression As String, _
Optional ByVal Delimiter As String, _
Optional ByVal Count As Long, _
Optional ByVal Compare As VbCompareMethod) As Variant
提示
编译错误:
Visual Basic 中不支持自动化类型怎么样引用它呢?附:工具-〉引用肯定是不行的,因为会提示
名称与已存在的模块、工程或对象冲突
这就是,这个VBA引用的VB For App版本很低,没有Split这些函数,我想用C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL中的Split函数,但是怎么都没有办法声明成功。我的模块级别的声明是这样的
Declare Function SplitA Lib "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6.DLL" ( _
ByVal Expression As String, _
Optional ByVal Delimiter As String, _
Optional ByVal Count As Long, _
Optional ByVal Compare As VbCompareMethod) As Variant
提示
编译错误:
Visual Basic 中不支持自动化类型怎么样引用它呢?附:工具-〉引用肯定是不行的,因为会提示
名称与已存在的模块、工程或对象冲突
解决方案 »
- vb发送邮件附件
- 求助,VB外文参考文献及access外文文献
- 能不能在ie或webbrowser的DocumentComplete中直接得到完成的document?
- 请问如何不使用控件数组,动态增加Label控件,并在Picture中显示。
- 编写一个托盘程序编译生成exe文件时候弹出对话框:请大家帮帮我。
- VB 可以实现强制类型转换吗?
- 高分求教
- 为什么不能加载RNAUI.dll,请高手给以提示!谢谢!
- 在线等候 窗体在启动时不是直接出现在屏幕上,而是由一个小的矩形逐渐扩散(从小变大)而成
- 下面程序,无论是 Grid 还是 TextBox, 要显示文字都不能正确显示!!
- 求一 SQL 语句
- 串口通信,刷卡读密码,请求技术支持。帮忙看一下对不对,感谢,打扰大家午觉了~~
另外,split函数你自己也可以写的,何必一定要……
' A replacement for the Split function under VB4 and VB5
'
' Note that the return value is a Variant that contains
' an array of stringsFunction Split(ByVal Text As String, Optional ByVal Delimiter As String = " ", _
Optional ByVal Limit As Long = -1, Optional CompareMethod As _
VbCompareMethod = vbBinaryCompare) As Variant
ReDim res(0 To 100) As String
Dim resCount As Long
Dim length As Long
Dim startIndex As Long
Dim endIndex As Long
length = Len(Text)
startIndex = 1
Do While startIndex <= length And resCount <> Limit
' get the next delimiter
endIndex = InStr(startIndex, Text, Delimiter, CompareMethod)
If endIndex = 0 Then endIndex = length + 1
' make room in the array, if necessary
If resCount > UBound(res) Then
ReDim Preserve res(0 To resCount + 99) As String
End If
' store the new element
res(resCount) = Mid$(Text, startIndex, endIndex - startIndex)
resCount = resCount + 1
startIndex = endIndex + Len(Delimiter)
Loop
' trim unused values
ReDim Preserve res(0 To resCount - 1) As String ' return the array inside a Variant
Split = res()End Function
Asc
_B_str_Chr
_B_var_Chr
_B_str_LCase
_B_var_LCase
_B_str_Mid
_B_var_Mid
_B_str_MidB
_B_var_MidB
InStr
InStrB
_B_str_Left
_B_var_Left
_B_str_LeftB
_B_var_LeftB
_B_str_LTrim
_B_var_LTrim
_B_str_RightB
_B_var_RightB
_B_str_Right
_B_var_Right
_B_str_RTrim
_B_var_RTrim
_B_str_Space
_B_var_Space
_B_var_StrConv
_B_str_String
_B_var_String
_B_str_Trim
_B_var_Trim
_B_str_UCase
_B_var_UCase
StrComp
_B_str_Format
_B_var_Format
Len
LenB
AscB
_B_str_ChrB
_B_var_ChrB
AscW
_B_str_ChrW
_B_var_ChrW
我觉得实在太少了,怎么完成split的功能啊!
我用了你的方法到程序里,还是提示
编译错误:
Visual Basic 中不支持自动化类型