Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

一个自定义函数来分离字符串的方法

时 间:2004-08-11 00:00:00
作 者:竹笛   ID:8  城市:上海  QQ:2851379730点击这里给张志发消息
摘 要:一个自定义函数来分离字符串的方法
正 文:

:请问该数据库中的type列,怎么用查询,以逗号将该数据分割开
:通过下面的自定义函数,结合查询来达到这一目的:
Function A(strType As String)
Dim x As Integer
x = InStr(strType, ",") - 2
A = Mid(strType, 2, x)
End Function
Function B(strType As String, strType2 As String)
    Dim x As Integer
    Dim typeTemp As String
    typeTemp = Mid(Replace(strType, strType2, ""), 3)
    x = InStr(typeTemp, ",") - 2
    If x > 0 Then
        B = Mid(typeTemp, 2, x)
    Else
        B = Mid(typeTemp, 2)
    End If

End Function
Function C(strType As String, strType2 As String, strType3 As String)
    Dim x As Integer
    Dim y As Integer
    Dim typeTemp As String
    x = Len(strType2 & strType3) + 6
    typeTemp = Mid(strType, x)
    y = InStr(typeTemp, ",") - 1
    If y > 0 Then
        C = Mid(typeTemp, 1, y)
    Else
        C = Replace(typeTemp, """", "")
    End If

End Function
Function strD(strType As String, strType2 As String, strType3 As String, strType4 As String)
    Dim x As Integer
    Dim typeTemp As String
    x = Len(strType2 & strType3 & strType4) + 6
    typeTemp = Mid(strType, x)
    strD = Mid(typeTemp, 2)

End Function

示  例:见下面的链接

更多参考:
论坛中本主题相关讨论帖子链接: cgi-bin/dispbbs.asp?boardID=90&ID=1905



Access软件网QQ交流群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助