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 "+".

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

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容