VBA Split ?

Discussion in 'AutoCAD' started by News, Mar 2, 2004.

  1. News

    News Guest

    All,
    I am trying to "explode" a string into individual characters.

    In this example, Picklayer ='s "TEST", but the msgbox displays TEST
    instead of T, then E, then S, etc. etc. etc.

    Dim PickLayer As String
    Dim NewLayer As AcadLayer
    Dim i As Long

    PickLayer = cmbLayers.Text
    Set NewLayer = ThisDrawing.Layers(PickLayer)
    ThisDrawing.ActiveLayer = NewLayer

    arrPickLayer = Split(PickLayer, "")

    For i = 0 To UBound(arrPickLayer)
    MsgBox arrPickLayer(i)
    Next
     
    News, Mar 2, 2004
    #1
  2. From VB Help on Split:
    delimiter Optional. String character used to identify substring
    limits. If omitted, the space character (" ") is assumed to be the
    delimiter. If delimiter is a zero-length string, a single-element array
    containing the entire expression string is returned.


    You can't use a zero-length string as the delimiter.
    If you want to break it up into letteers:

    For i = 0 To len(picklayer)
    MsgBox mid$(picklayer, i,1)
    Next
     
    Allen Johnson, Mar 2, 2004
    #2
  3. News

    News Guest

    thanks for the response, it works perfect.

    and for now on i'll try and keep my vba in the vba group ;)
     
    News, Mar 2, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.