I am getting a little piece of code from a client to a server, which looks like this:
"NAME: " & My.Computer.Name & "; IP: " & GetExternalIp()
This Code is beeing recieved by the server in a textbox(txt.Chat) with multiline.. So I'm actually kind of re-asking this, because the question I asked wasn't really understandable. Some user answered this:
Dim stringFromClient As String = "Name: xxx-PC; IP: xxx.xxx.xxx.xxx"
Dim values() As String = stringFromClient.Split(";")
Dim name As String = values(0).Split(":").Last.Trim
Dim IP As String = values(1).Split(":").Last.Trim
Debug.Print("name = " & name)
Debug.Print("IP = " & IP)
I tried this out, but the problem was that I was getting this output: "Name: xxx-PC; IP: xxx.xxx.xxx.xxx" which isn't actually what i want.. i dont know how to set the "stringfromClient" string correctly.
答案 0 :(得分:0)
To set the string do this:
Dim stringFromSomewhere As String = "NAME: " & My.Computer.Name & "; IP: " & GetExternalIp()
To extract the values do this:
Dim values() As String = stringFromSomewhere .Split(";")
Dim name As String = values(0).Split(":").Last.Trim
Dim IP As String = values(1).Split(":").Last.Trim
Debug.Print("name = " & name)
Debug.Print("IP = " & IP)
"name" and "IP" will contain the name and IP data from the original string