Search notes:

VBA class: StringJoiner - join strings on a given separator

option explicit

sub testStringJoiner() ' {

    dim sj as stringJoiner : set sj = new StringJoiner

    sj.init(", ")

    sj.add("foo")
    sj.add("bar")
    sj.add("baz")

    debug.print(sj)

end sub ' }

Source code

' vi: ft=vb
'
' V0.1

option explicit

private first   as boolean
private joiner  as string
private buf     as stringBuffer

public sub init(joiner_ as string, optional bufSize as long = 1000) ' {
    first  = true
    joiner = joiner_

    set buf = new stringBuffer : buf.init(bufSize)
end sub ' }

function add(txt as variant) as string ' {

    if first then
       buf.append(txt)
       first = false
    else
       buf.append(joiner & txt)
    end if

end function ' }

function value() as string ' {
     attribute value.vb_userMemId = 0
     value = buf
end function ' }
Github repository VBAModules, path: /Common/Text/StringJoiner.cls

See also

StringJoiner requires the StringBuffer class.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758200331, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/modules/Common/Text/StringJoiner/index(87): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78