How to create this string?

S

Shapper

Hello,

I am trying to create a simple code but I am having problems:

1. Create an array of integers: myArray = (1,0,1,0)
2. Detect the size of this array.
3. Create a string like this:

"item" & myArray(0) & "item" & myArray(1) ...

In this case I would get the string:
"item1item0item1item0"

Can someone help me out?

Thanks,
Miguel
 
V

vMike

Shapper said:
Hello,

I am trying to create a simple code but I am having problems:

1. Create an array of integers: myArray = (1,0,1,0)
2. Detect the size of this array.
3. Create a string like this:

"item" & myArray(0) & "item" & myArray(1) ...

In this case I would get the string:
"item1item0item1item0"

Can someone help me out?

Thanks,
Miguel
You could look into the split function, getupperbound(0) and the
stringbuilder function as follows

dim strArray() as string = split("0,2,4,5,6,1",",")
dim intCount as int32 = strArray.getUpperbound(0)

strArray will yield and array of the 0, 2 etc starting at the index of
strArray(0) and intCount will equal 6. So you last value will be strArray(5)
..
Using stringbuilder.append method you can build your string

Hope this helps.
Mike
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top