Crew algemeen |
|
Private Sub btnBevestigen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBevestigen.Click
Dim request As WebRequest = WebRequest.Create("http://hari.b-holding.be/Hafas/bin/query.exe/nn?seqnr=1&ident=0m.0522413.1189198890&OK#focus")
Dim strPost1, strPost2 As String
Dim byteArray1,byteArray2 As Byte()
strPost1 = txtTextbox1.text.ToString
strPost2 = txtTextbox2.text.Tostring
byteArray1 = Encoding.UTF8.GetBytes(strPost1)
byteArray2 = Encoding.UTF8.GetBytes(strPost2)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray1, 0, byteArray1.Length)
dataStream.Write(byteArray2, 0, byteArray2.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Textbox99.text &= CType(response, HttpWebResponse).StatusDescription
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
'Textbox99.text &= vbCrLf & responseFromServer
reader.Close()
dataStream.Close()
response.Close()
End Sub
Private Sub btnBevestigen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBevestigen.Click Dim request As WebRequest = WebRequest.Create("http://hari.b-holding.be/Hafas/bin/query.exe/nn?seqnr=1&ident=0m.0522413.1189198890&OK#focus") Dim strPost1, strPost2 As String Dim byteArray1,byteArray2 As Byte() strPost1 = txtTextbox1.text.ToString strPost2 = txtTextbox2.text.Tostring byteArray1 = Encoding.UTF8.GetBytes(strPost1) byteArray2 = Encoding.UTF8.GetBytes(strPost2) request.Method = "POST" request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = byteArray.Length Dim dataStream As Stream = request.GetRequestStream() dataStream.Write(byteArray1, 0, byteArray1.Length) dataStream.Write(byteArray2, 0, byteArray2.Length) dataStream.Close() Dim response As WebResponse = request.GetResponse() Textbox99.text &= CType(response, HttpWebResponse).StatusDescription dataStream = response.GetResponseStream() Dim reader As New StreamReader(dataStream) Dim responseFromServer As String = reader.ReadToEnd() 'Textbox99.text &= vbCrLf & responseFromServer reader.Close() dataStream.Close() response.Close() End Sub
zoiets? Maar titjes zal wrs met een betere oplossing komen, dit is hardcoded omdat ik te wijnig ervaring met VB.NET heb om dit anders te doen....
//edit:
maar aub, declareer je var's bovenaan, en niet waar je ze nodig hebt... |