首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >vb.net在两个字符之前获取文本并使用它

vb.net在两个字符之前获取文本并使用它
EN

Stack Overflow用户
提问于 2014-02-16 14:58:41
回答 1查看 368关注 0票数 0

有人能帮我如何使用这些数据吗?

代码语言:javascript
运行
复制
Dim String as String = "thing=lol1 thing=lol2 thing=lol3 ..."

我想以某种方式使用这些数据:

代码语言:javascript
运行
复制
For i As Integer
Dim webClient1 As New System.Net.WebClient
Dim result As String = webClient1.DownloadString("http://pr2hub.com/submit_rating.php?level_id=" + lol1)
Next

下一个是

代码语言:javascript
运行
复制
Dim result As String = webClient1.DownloadString("http://pr2hub.com/submit_rating.php?level_id=" + lol2)

然后

代码语言:javascript
运行
复制
Dim result As String = webClient1.DownloadString("http://pr2hub.com/submit_rating.php?level_id=" + lol3)

那么,我如何使用"=“和”“之间的数据呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-16 15:05:50

因此,基本上,您有一个包含键/值对的字符串,该字符串由空格分隔。您可以使用Split方法提取必要的信息:

代码语言:javascript
运行
复制
Dim result as String = "thing=lol1 thing=lol2 thing=lol3 ..."
Dim tokens = result.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)
For Each token As String In tokens
    Dim kvp = token.Split(New String() {"="}, StringSplitOptions.RemoveEmptyEntries)
    If kvp.Length > 1 Then
        Dim key as String = kvp(0)
        Dim value as String = kvp(1)
        ' Do something with the key and value here
    End If
Next
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21812838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档