Consulting

Results 1 to 6 of 6

Thread: Different size in a joined string

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    17
    Location

    Different size in a joined string

    Hi all,

    I would like to ask in case anyone has experience about this.

    So, I have a joined string that has different size every time I input it from matlab.

    For example:
    from Matlab into VBA
     input_to_vba = strjoin {'A, B, C, D'}
    In this case, total number of the string is 4 (A to D).

    in VBA
    input_split = split(input_to_vba, '%')
    A = input_split(1)
    ...
    D = input_split(4)
    I will have different string input everytime I run the matlab together with VBA. Can VBA automatically recognize it and make the split?

    Thanks a lot!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,718
    Location
    What exactly does the string input_to_vba look like when it gets to VBA?


    input_split = split(input_to_vba, '%')
    A = input_split(1) 
    ... 
    D = input_split(4)

    "ABCD" or "A,B,C,D" or "A, B, C, D" or ... ?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Nov 2015
    Posts
    17
    Location
    Hi Paul,

    The input will look like "A%B%C%D"

    and after split it will be separated into A alone, B alone, etc.

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,735
    Location
    What do you actually want to do with it? You can simply use Split and assign to an array and then loop through that as and when needed using Lbound and Ubound.
    Be as you wish to seem

  5. #5
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,710
    Location
    input_split = split(input_to_vba, "%") 'Doublequotes
    For i = Lbound(input_split) to UBound(input_split)
    MsgBox input_split(i)
    Next
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  6. #6
    VBAX Regular
    Joined
    Nov 2015
    Posts
    17
    Location
    Oh, okay. Thanks a lot guys!
    I am not really familiar with the syntax used in vba.

    Thanks for helping!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •