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