dongqixuan3112 2012-05-13 03:44
浏览 31
已采纳

在某一点分裂响应

I had a question earlier involving php and mysql on this same project,

This is .net, Im trying to read the source of my php response, and stop after a certain character or phrase, in which mine is <br />

I Tried google, and got no luck, Im hoping somebody here can save me!

here is my current code.

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles     Button1.Click
        Dim request As System.Net.HttpWebRequest =    System.Net.HttpWebRequest.Create("http://mywebsite/db.php?hwid=" + TextBox1.Text)
        Dim response As System.Net.HttpWebResponse = request.GetResponse()
        Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
    Dim name As String = sr.ReadToEnd
        If name = "" Then
            MessageBox.Show("HWID Not Activated!", "Error: Invalid HWID")
        Else
            MessageBox.Show("Welcome, " + name)
            Me.Hide()
            Form1.Show()
        End If
    End Sub

I Want to stop reading everything after the source at <br />

  • 写回答

1条回答 默认 最新

  • dqcd84732 2012-05-14 19:45
    关注

    You can find where the "<br />" is and get the string before that:

    Dim s = "Andrew<br />Morton"
    Dim brIndex = s.IndexOf("<br />")
    Dim myName As String = ""
    If brIndex >= 0 Then
        myName = s.Substring(0, brIndex)
    End If
    Console.WriteLine(myName)
    ' outputs: Andrew
    

    Also, you need to call .Close() on the HttpWebResponse.

    And, the string concatenation operator in VB.NET is "&", not "+".

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面