Valhalla Legends Forums Archive | Visual Basic Programming | Split help.

AuthorMessageTime
GoSu_KaOs
How can I make this. I got Text1.text and Listview1. I want to make it so if  you type " Item1:Item2" in the textbot, then save it. After it loads everything in to listview1, I want "Item1" to go to 1 column and "Item2" to go into another column.
December 4, 2004, 1:59 AM
Networks
[code]
Item1 = Split(Usertexthere, ":")(0)
Item2 = Split(Usertexthere, ":")(1)
[/code]

Another way:

[code]
Dim Splt() as string
Splt() = Split(Usertexthere, ":")

Item1 = Splt(0)
Item2 = Splt(1)
[/code]

(Which ever is more convient for you.)
December 4, 2004, 2:58 AM
R.a.B.B.i.T
Just a forenot: the first method will be slower if you have more than a few splits, however.
December 4, 2004, 5:17 AM
Networks
Split would be more cool if you could place an 'or' in it like:
split(string, "+" or "-")
December 4, 2004, 5:28 AM
GoSu_KaOs
The second meathod worked for me. Thx
December 4, 2004, 5:29 AM
HdxBmx27
[quote author=Networks link=topic=9771.msg90988#msg90988 date=1102138096]
Split would be more cool if you could place an 'or' in it like:
split(string, "+" or "-")
[/quote]

[code]replace(string, "-", "")
Bla = split(string, "+")[/code]
??
~-~(HDX)~-~
December 4, 2004, 5:40 AM
LivedKrad
[quote author=HdxBmx27 link=topic=9771.msg90990#msg90990 date=1102138843]
[quote author=Networks link=topic=9771.msg90988#msg90988 date=1102138096]
Split would be more cool if you could place an 'or' in it like:
split(string, "+" or "-")
[/quote]

[code]replace(string, "-", "")
Bla = split(string, "+")[/code]
??
~-~(HDX)~-~
[/quote]
Although that works, it poses two problems. One being that it is slower to do two operations that would otherwise be in one intrinsic function already. The second is that it could replace an instance of "-" that you *may have* wanted to keep a "+". I would assume this because - and + are probably denoting the adding/subtracting of access flags from a user. Now, the way you *could* use that would be to fire a Boolean if "-" is found in the command. That way, you can adjust control flow to use the proper procedures accordingly.

Edit: BTW, that's also slow too. :P
December 4, 2004, 3:05 PM
HdxBmx27
Ah ok, if you wanted to do it that way you could just do a loop and then split each part by "-", but this is extreemly slow, so Ya i get what your saying. O an crap I jsut noticed i did it worng in my post it was suposto be String = eplace(string, "-", "+") but meh.
~-~(HDX)~-~
December 5, 2004, 8:44 AM
Networks
[quote author=LivedKrad link=topic=9771.msg91000#msg91000 date=1102172719]
[quote author=HdxBmx27 link=topic=9771.msg90990#msg90990 date=1102138843]
[quote author=Networks link=topic=9771.msg90988#msg90988 date=1102138096]
Split would be more cool if you could place an 'or' in it like:
split(string, "+" or "-")
[/quote]

[code]replace(string, "-", "")
Bla = split(string, "+")[/code]
??
~-~(HDX)~-~
[/quote]
Although that works, it poses two problems. One being that it is slower to do two operations that would otherwise be in one intrinsic function already. The second is that it could replace an instance of "-" that you *may have* wanted to keep a "+". I would assume this because - and + are probably denoting the adding/subtracting of access flags from a user. Now, the way you *could* use that would be to fire a Boolean if "-" is found in the command. That way, you can adjust control flow to use the proper procedures accordingly.

Edit: BTW, that's also slow too. :P
[/quote]

haha Krad knew exactly what I was referring to :). I had to use a loop.
December 5, 2004, 8:17 PM

Search