How to go from string of numbers to array of numbers using split?

How to go from string of numbers to array of numbers using split?

Anonymous
Not applicable
1,676 Views
2 Replies
Message 1 of 3

How to go from string of numbers to array of numbers using split?

Anonymous
Not applicable

Hi, 

 

I am working on a macro which has to draw a combination of the same designs but with different parameters (e.g. length). In an userform you have to put in multiple lengths so you get designs of these lengths. 

To draw these designs I need an array which contains these values of lengths. To do this I use the following lines: 

 

Dim length(10) As Double                                  'define length of the designs
Dim lengthST As String                                     'ST is string
Dim lengthSP() As String                                'SP is splitted string

 

lengthST = inputwindow.lengthTextBox.Text
lengthSP = Split(lengthST, ",")
For s = 0 To UBound(lengthSP)
length(s) = lengthSP(s) + 0
Next s
If UBound(lengthSP) < 1 Then length(0) = Val(lengthST)

 

From these lines I don't get an error, but lengthSP does not have a value, or isn't even an array I think. 

Can someone explain to me my mistake, because I already saw in examples that this should work.

 

Thanks in advance! 

 

 

0 Likes
Accepted solutions (1)
1,677 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor

What is the value of lengthST?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 3

stefan.hofer
Advocate
Advocate
Accepted solution

 

lengthST = "10,20,30,40,50"
Dim parts As String() = lengthST.Split(New Char() {","c})

 

0 Likes