我的程序有
FlatTextBox1
FlatButton1
FlatAlertBox1
所以,我已经做到了,当您在文本框中键入内容并单击按钮时,它会从网址请求并将结果返回到警告框。我的问题是,我如何制作它只返回第一个数字和点?例如,如果它返回:
Success: 255.255.255.255 <br><br><br> Old Success: 127.0.0.1
我希望它只显示
255.255.255.255
答案 0 :(得分:0)
最简单的方法是通过substring:
进行字符串操作 Dim sResult As String = "Success: 255.255.255.255 <br><br><br> Old Success: 127.0.0.1" ' This is hardcoded for the example
Dim nIndex1 As Int32 = sResult.IndexOf(" ") ' Find the first blank space character (after Success:)
Dim nIndex2 As Int32 = sResult.IndexOf("<br>") ' Find the first br tag (after the space which is after the ip address we want to capture)
sResult = sResult.Substring(nIndex1, nIndex2 - nIndex1).Trim ' Use substring to get the ip address and trim off the excess spaces
答案 1 :(得分:0)
您可以使用string.remove
Dim sResult As String = "Success: 255.255.255.255 <br><br><br> Old Success: 127.0.0.1"
Dim break = sResult.IndexOf("<br>") 'find the first time it says "<br>"
Dim sresult = sResult.Remove(break) 'remove from the string