[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.net - VB.net Array

Posted on 2012-09-20
5
Medium Priority
?
353 Views
Last Modified: 2012-09-25
Hello,

I am trying to capture the HTTP Response, parse it and take appropriate actions based on the recieved data.

I hope someone can advise how can I go about doing this correct.

The response I get from the URL is

OK:22059

OR

OK:22059
OOS:2745
OOS:2752
OOS:2745
OOS:2752

If its only OK:22059, then I can easily capture and store it in the DB, the problem is when the response in more than 1 line.

 Dim NetResultString() As String
If Not ResponseString Is Nothing And ResponseString <> "" Then
   If ResponseString.Contains("OK") Then
   	NetResultString = ResponseString.Split(Environment.NewLine)
        TransactionID = NetResultString(0).Substring(NetResultString(0).IndexOf(":") + 1, NetResultString(0).IndexOf(vbLf) - NetResultString(0).IndexOf(":") - 1)
   	If (TransactionID <> "") AndAlso (PrevOrderID <> OrderID) Then
   		UpdateWebOrderStatus(OrderID, "ORDER_SAVED_ON_Net", "WebSystem")
   		AddOrderNotes(OrderID, "Order Detail Saved Successfully. Net TransID: " & TransactionID, "WebSystem")
   	End If
   	If NetResultString(1) <> "" Then
   		LineItemID = NetResultString(1).Substring(NetResultString(0).IndexOf(":") + 1, NetResultString(1).IndexOf(vbLf) - NetResultString(1).IndexOf(":") - 1)
   		UpdateWebOrderStatus(OrderID, "ORDER_Net_MANUAL_STOCK", "WebSystem")
   		AddOrderNotes(OrderID, "Partial Order Detail Saved On Net Due To An Out Of Stock Item. ProductID: " & GetProdIDByNetID(LineItemID), "WebSystem")
   		CommonFunctions.SendEmail(My.Settings.AdminEmailAddress, My.Settings.OfficeAdminEmailAddress, "Net URL Data Post Error - Unable to save an Item record.", GetProdIDByNetID(LineItemID) & " is out of stock")
        End If
        ' NetResultString(2) 
        ' NetResultString(3) 
        ' NetResultString(4) 
   End If       
End If

Open in new window


I hope can someone advise how can I loop it through the array object so that if they more than 1 OOS item, it will do the same thing for all.

Thanks
F
0
Comment
Question by:faisalkh
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38418798
Try following

For Each response in ResponseString.Split(VBCRLF)
    'Above code here to deal with each line of response string
Next
0
 

Author Comment

by:faisalkh
ID: 38422361
Hi,
I have tried that but it will only pick the first string from the below ie: "OK:22067" and come out of the loop.
>> Response = "OK:22067OOS:2752"
I am trying to loop it through so that next time it should go to the next if condition
Thanksresponse
Dim Response As String

For Each Response In ResponseString.Split(vbCrLf)
   If Response.Contains("OK") Then   	 
        TransactionID = Response.Substring(Response.IndexOf(":") + 1, Response.IndexOf(vbLf) - Response.IndexOf(":") - 1)
        AddOrderNotes(OrderID, "Order Detail Saved Successfully. Net TransID: " & TransactionID, "WebSystem")
   	
   ElseIf Response.Containts("OOS") Then
   	LineItemID = Response.Substring(Response.IndexOf(":") + 1, Response.IndexOf(vbLf) - Response.IndexOf(":") - 1)  		 
   	AddOrderNotes(OrderID, "Partial Order Detail Saved On Net Due To An Out Of Stock Item. ProductID: " & GetProdIDByNetID(LineItemID), "WebSystem")
   		
   End If       
End If

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38422935
>>> Response = "OK:22067OOS:2752"

That's because there does not seem to be a line break between the elements.
0
 

Author Comment

by:faisalkh
ID: 38423752
Please can you see the attachment? You will notice that there is a carriage return between the strings

Thanks
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38423775
Try using different characters to see which one splits it: VBCRLF, VBCR, CRLF
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question