|
-
May 22nd, 2007, 01:22 PM
#1
Thread Starter
Addicted Member
VB "explode"
Im not sure if anyone here knows PHP, but there is a command called "explode" to break apart a string. Is there any thing similar to this in Visual Basic?
-
May 22nd, 2007, 01:25 PM
#2
Re: VB "explode"
The Split command is what you're looking for.
-
May 22nd, 2007, 01:25 PM
#3
Re: VB "explode"
Depends on the end goal. If you need to break it apart by a delimiter, than use the Split() function. You could also use the .ToCharArray() function to break it apart into a string array, each member containing one character of the string.
-
May 22nd, 2007, 01:27 PM
#4
Thread Starter
Addicted Member
Re: VB "explode"
my goal is to take the output of a shell command and use only certain parts of it
Would i use split() for that?
and by the way, its going to need to be broken apart by spaces.
-
May 22nd, 2007, 01:30 PM
#5
Re: VB "explode"
Then yes. Bring it in as a string. I'll call it myStr. Then run this command:
Dim strArray() As String = myStr.Split(" ")
-
May 22nd, 2007, 01:30 PM
#6
Thread Starter
Addicted Member
Re: VB "explode"
then when i want to retrieve it, what variable would i use?
-
May 22nd, 2007, 01:31 PM
#7
Re: VB "explode"
Split would work for that, depending on if the return string had consistant delimiters. You could also use the regular expression component if your parsing needs were more complex.
-
May 22nd, 2007, 01:31 PM
#8
Re: VB "explode"
You would call strArray and whatever element you want. So if you wanted the second element, you'd call for strArray(1), since arrays are 0-based.
-
May 22nd, 2007, 01:33 PM
#9
Thread Starter
Addicted Member
Re: VB "explode"
ok. thanks a lot for the quick replies, ill try that when i get back home and reply whether it worked or not.
I guess its very similar to PHP
-
May 22nd, 2007, 01:34 PM
#10
Thread Starter
Addicted Member
Re: VB "explode"
one more thing,
the string that i want to break apart would be set equal to StrArray(), right?
-
May 22nd, 2007, 01:35 PM
#11
Re: VB "explode"
Yes, and its elements would be strArray(0) to strArray(x) depending on how many elements it had.
-
May 22nd, 2007, 01:37 PM
#12
Thread Starter
Addicted Member
-
Oct 8th, 2007, 02:02 PM
#13
New Member
Re: VB "explode"
I am trying to parse a string who's delimiter is a newline. Do you know how I could do this in VBScript?
Thanks in advance!!
-
Oct 8th, 2007, 11:20 PM
#14
Re: VB "explode"
 Originally Posted by chankew
I am trying to parse a string who's delimiter is a newline. Do you know how I could do this in VBScript?
Thanks in advance!!
This is a VB.NET forum, not VBScript. If you take a look at the site home page it tells you what each forum is for. There is one dedicated to VBScript and this is not it.
-
Feb 24th, 2010, 07:02 AM
#15
New Member
Re: VB "explode"
I want to split a string on basis of a repeated string, or may be a delimiter composed of more than one characters.
Is there any function available to do that.
Substring is also a function but it takes integer index values which is not applicable to my case?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|