467,161 Members | 865 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

Split settings

Hello... I have a question about Split function:
I need to split text ("ABCDEFGH") in letters.. and what I have to write in "Delimiter of string"??
for e.g.
Expand|Select|Wrap|Line Numbers
  1. Split("ABCDEFGH", "", 1)
isn't working. :(

PS.: Sorry about my english.
Nov 23 '06 #1
  • viewed: 1831
Share:
5 Replies
I found out:
Expand|Select|Wrap|Line Numbers
  1. variable.Substring(i, 1)
But now is another problem... How can i add this value to array?
e.g.
my_array(i) = variable.Substring(i, 1)

can I put "i" in array value id?
Nov 23 '06 #2
As far as i know it would have to be my_array(0) = variable.Substring(i, 1) , A number not i
Nov 23 '06 #3
100+
As far as i know it would have to be my_array(0) = variable.Substring(i, 1) , A number not i
hi

suppose your string strValue holds "2,e,f,5,6,h,u"

then

array=split(strValue,",") 2nd argument is delimiter

first item of the array will be array(0), value 2 etc
Nov 24 '06 #4
Expert 8TB
I found out:
variable.Substring(i, 1)
But now is another problem... How can i add this value to array?
e.g.
my_array(i) = variable.Substring(i, 1)
can I put "i" in array value id?
What you need to do is write a loop to go through one character at a time. Something along these lines...
Expand|Select|Wrap|Line Numbers
  1. S = "ABCDEFGH"
  2. For i = 1 To Len(S)
  3.   my_array(i) = Mid(S, i, 1)
  4. Next
However, this is VB6 code. From the Substring you've used, I suspect you're using VB.Net. They are similar in some ways, different in others. The same sort of logic should apply here though - loop through the characters, placing them into the array elements.

As albertw pointed out, to use Split there has to be some delimiter character in the string, on which to split. Such as spaces between words, or commas netween data fields, etc.
Nov 24 '06 #5
1GB
I found out:
Expand|Select|Wrap|Line Numbers
  1. variable.Substring(i, 1)
But now is another problem... How can i add this value to array?
e.g.
my_array(i) = variable.Substring(i, 1)

can I put "i" in array value id?
Hi. Try this;
Expand|Select|Wrap|Line Numbers
  1. Dim ar() As String
  2. Dim MyString As String
  3. Dim i As Integer
  4.  
  5. MyString = "ABCDEFGHIJK"
  6. ReDim ar(Len(MyString) - 1)
  7.  
  8. For i = 0 To UBound(ar)
  9.    ar(i) = MyString.Substring(i + 1, 1)
  10. Next i
  11.  
Nov 24 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Stu Cazzo | last post: by
9 posts views Thread by Will McGugan | last post: by
4 posts views Thread by Itzik | last post: by
5 posts views Thread by kurt sune | last post: by
2 posts views Thread by Lars | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.