Вы можете сделать это с помощью Split
. Например, я делю строку, которую я мог бы сохранить, поэтому мне не пришлось бы Split
ее снова. Однако это проще понять:
Dim s as String = "hello:world@yay" 'This can be a string from a loop.
Dim hello As String = s.Split(":")(0) 'Get everything before colon.
Dim world As String = s.Split(":")(1).Split("@")(0) 'Get everything after colon, and split the result again, grabbing everything before the amp.
Dim yay As String = s.Split(":")(1).Split("@")(1) 'Get everything after colon, and split the result again, grabbing everything after the amp.
Если вы читаете из текстового файла, например
Dim objReader As New StreamReader("c:\test.txt")
Dim s As String = ""
Dim hello As String
Dim world As String
Dim yay As String
Do
s = objReader.ReadLine()
If Not s Is Nothing Then
hello = s.Split(":")(0)
world = s.Split(":")(1).Split("@")(0)
yay = s.Split(":")(1).Split("@")(1)
End If
Loop Until s Is Nothing
objReader.Close()