Hi All!
Trying to run the following code but am receiving an string to integer error. Basically, I am running a report through code and trying to retrieve a number from a line of code by removing the line description and spaces. Having problems trying to figure out how to do that.
Any help would be greatly appreciated. The line of code returned is: " Grand Total 2,456.25 " and I want to retrieve just the number. The underlined code is where I am receiving my error.
Thanks
Trying to run the following code but am receiving an string to integer error. Basically, I am running a report through code and trying to retrieve a number from a line of code by removing the line description and spaces. Having problems trying to figure out how to do that.
VB.NET:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strURL As String
Dim byteResponse As Byte()
Dim strResponse As String
Dim finalURL As String
Dim CustomerClass As String = "DMO"
Dim BeginDate As DateTime = "6/1/2009"
Dim EndDate As DateTime = "6/30/2009"
Dim rsDB As String = "Test"
Dim rsUN As String = "userid"
Dim rsPW As String = "afjlafja;jf"
strURL = "http://ether/cgi-bin/reportsrv.cgi?DATABASE=" & rsDB
strURL += "&PASSWORD=" & SafeStr(rsPW)
strURL += "&USERNAME=" & SafeStr(rsUN)
strURL += "&REPORTEXE=arrrun02&CATEGORY=ARR&ACTION=GO&REPORT=Price Protection Detail|arrprpro|armenu|&REPORTNAME=arrprpro&ENTRYORDER=PARMf1|PARMf2|PARMf3|&COLCOUNT=3&ENTRYTYPE=STANDARD|DATE|DATE|"
finalURL = strURL
finalURL += "&PARMf1=" & SafeStr(CustomerClass)
finalURL += "&PARMf2=" & BeginDate.ToShortDateString
finalURL += "&PARMf3=" & EndDate.ToShortDateString
Dim wc As New System.Net.WebClient
byteResponse = wc.DownloadData(finalURL)
strResponse = System.Text.Encoding.ASCII.GetString(byteResponse)
Dim sArryResponse As String() = strResponse.Split(vbLf)
strResponse = ""
Dim TicketBegun As Boolean = False
Try
For Each line As String In sArryResponse
If line.StartsWith("ARRPRPRO") Then
TicketBegun = True
End If
If line.Contains("Grand Total") Then
strResponse += vbLf & line
End If
Next
If strResponse = "" Then
strResponse = 0
Else
[U]strResponse = strResponse.Remove("Grand Total").Trim[/U]
End If
Catch ex As Exception
strResponse = ex.Source & " " & ex.Message
End Try
Label1.Text = strResponse
End Sub
Private Function SafeStr(ByVal iStr As String) As String
Return iStr.Replace("'", "\'")
End Function
Any help would be greatly appreciated. The line of code returned is: " Grand Total 2,456.25 " and I want to retrieve just the number. The underlined code is where I am receiving my error.
Thanks