Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4,VB5,VB6,VBS
Expertise: Intermediate
Apr 1, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

JoinQuoted - A Join variant that encloses string values in quotes

' Join variant that works with arrays of any type
' and that encloses string values between quotes
' ARR is the array whose element must be joined
' SEPARATOR is the separator char (default is comma)
' QUOTED is the character used to quote string values
'     use a two-char string (eg "{}") if the openining
'     and closing quote chars are different
'     use a null string to suppress quoting feature

Function JoinQuoted(arr As Variant, Optional ByVal Separator As String = ",", _
    Optional ByVal Quotes As String = """") As String
    Dim res As String
    Dim index As Long
    For index = LBound(arr) To UBound(arr)
        If VarType(arr(index)) <> vbString Then
            res = res & Separator & arr(index)
            ' the following code works correctly if
            ' LEN(Quotes) is 0,1,2
            res = res & Separator & Left$(Quotes, _
                1) & arr(index) & Right$(Quotes, 1)
        End If
    ' drop the first separator
    JoinQuoted = Mid$(res, Len(Separator) + 1)

End Function

Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date