How do I detect for a specific character in a string in VB.NET? -



How do I detect for a specific character in a string in VB.NET? -

okay, in programme i'm working on in vb.net i'm trying create can take in list of strings (each on different line). each line want take in line, , break 3 parts. first part goes origin of string first colon in string, sec part goes first colon @ symbol, , lastly part goes @ symbol end of string.

for example, i'd take in line of series of lines: hello:world@yay

i'd want break 3 separate strings of "hello", "world", , "yay".

how such thing in vb.net?

you can accomplish split. illustration purposes, re-splitting string have saved off, wouldn't have split again. however, it's simpler understand way:

dim s string = "hello:world@yay" 'this can string loop. dim hello string = s.split(":")(0) 'get before colon. dim world string = s.split(":")(1).split("@")(0) 'get after colon, , split result again, grabbing before amp. dim yay string = s.split(":")(1).split("@")(1) 'get after colon, , split result again, grabbing after amp.

if you're reading text file, e.g.

dim objreader new streamreader("c:\test.txt") dim s string = "" dim hello string dim world string dim yay string s = objreader.readline() if not s nil hello = s.split(":")(0) world = s.split(":")(1).split("@")(0) yay = s.split(":")(1).split("@")(1) end if loop until s nil objreader.close()

vb.net string character detection

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -