PDA

View Full Version : [SOLVED:] Different size in a joined string



evalent
12-29-2015, 08:25 AM
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!

Paul_Hossler
12-29-2015, 08:50 AM
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 ... ?

evalent
12-29-2015, 11:46 PM
Hi Paul,

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

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

Aflatoon
12-30-2015, 02:15 AM
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.

SamT
12-30-2015, 02:16 AM
input_split = split(input_to_vba, "%") 'Doublequotes
For i = Lbound(input_split) to UBound(input_split)
MsgBox input_split(i)
Next

evalent
12-30-2015, 02:52 AM
Oh, okay. Thanks a lot guys!
I am not really familiar with the syntax used in vba.

Thanks for helping!