[AccessD] Turn a string into an array
Stuart McLachlan
stuart at lexacorp.com.pg
Thu Aug 19 15:54:15 CDT 2021
Also, it may be appropriate to use: something like
Public Sub ArrayDemo()
Dim s As String
Dim Elements() As String
s = "123, 456, 789"
s = Replace(s, " ", "")
Elements = Split(s, ",")
Debug.Print Join(Elements(), vbLf)
End Sub
On 20 Aug 2021 at 6:43, Stuart McLachlan wrote:
> A handy little trick for debugging to replace your multi-line
> For...Next loop :)
>
> Debug.Print Join(Elements(), vbLf)
> or
> Msgbox Join(Elements(), vbLf)
>
>
> On 19 Aug 2021 at 12:37, Gustav Brock via AccessD wrote:
>
> Try this demo:
> >
> > <code>
> > Public Sub ArrayDemo()
> >
> > Const Sample As String = "123, 456, 789"
> >
> > Dim Elements() As String
> > Dim Index As Integer
> >
> > Elements = Split(Sample, ",")
> >
> > For Index = LBound(Elements) To UBound(Elements)
> > Debug.Print Elements(Index),
> > Elements(Index) = Trim(Elements(Index))
> > Debug.Print Elements(Index)
> > Next
> >
> > End Sub
> > </code>
> >
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
More information about the AccessD
mailing list