473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

string to string collection

I have a string that is in the format of a url query string, but it is not a
query string.
"RESULT=126&PNREF=V54A0A779FD7&RESPMSG=Under review by Fraud
ice&AUTHCODE=422PNI&AVSADDR=N&AVSZIP=N&IAVS=N&PREF PSMSG=Review"
It's a return from verisign

What is the easiest way to split this up into string collection?
of type stringcollection so that i can get to the value pairs?

there has to be an easy way t odo this
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
Nov 21 '05 #1
5 3920
is this the best way (or even a good way)
Dim strval As NameValueCollection = New NameValueCollection
Dim rsp() As String
rsp = ResponseOut.Split("&")
Dim s As String
For Each s In rsp
strval.Add(s.Split("=")(0), s.Split("=")(1))
Next
Me.lblResults.Text &= strval.Item("RESULT")
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"WebBuilder451" wrote:
I have a string that is in the format of a url query string, but it is not a
query string.
"RESULT=126&PNREF=V54A0A779FD7&RESPMSG=Under review by Fraud
ice&AUTHCODE=422PNI&AVSADDR=N&AVSZIP=N&IAVS=N&PREF PSMSG=Review"
It's a return from verisign

What is the easiest way to split this up into string collection?
of type stringcollection so that i can get to the value pairs?

there has to be an easy way t odo this
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes

Nov 21 '05 #2
WebBuilder,

Almost every day I see something new in this newsgroups. I did not know this
collection exist.

However, what can be wrong with your code when it is working (I did not
check it). In my opinion does it look nice.

Beneath, only to make the code you wrote more compact, not the syntax (2003
and newer)

\\\
Dim strval As New NameValueCollection
Dim rsp() As String = ResponseOut.Split("&")
For Each s as String in rsp
strval.Add(s.Split("=")(0), s.Split("=")(1))
Next
Me.lblResults.Text &= strval.Item("RESULT")
///

I hope this helps someting

Cor

Nov 21 '05 #3
thanks!!!!
I discovered this class while trying to find a solution. It's light weight
and will work well for short lists. It's about time i posted something that
was helpful!!
your feed back made my day!
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Cor Ligthert [MVP]" wrote:
WebBuilder,

Almost every day I see something new in this newsgroups. I did not know this
collection exist.

However, what can be wrong with your code when it is working (I did not
check it). In my opinion does it look nice.

Beneath, only to make the code you wrote more compact, not the syntax (2003
and newer)

\\\
Dim strval As New NameValueCollection
Dim rsp() As String = ResponseOut.Split("&")
For Each s as String in rsp
strval.Add(s.Split("=")(0), s.Split("=")(1))
Next
Me.lblResults.Text &= strval.Item("RESULT")
///

I hope this helps someting

Cor

Nov 21 '05 #4
Kes,
The only change I would make to your & Cor's code is to only do the
s.Split("=") once:

Dim strval As New System.Collections.Specialized.NameValueCollection
Dim rsp() As String = responseout.Split("&"c)
For Each s As String In rsp
Dim pair() As String = s.Split("="c)
strval.Add(pair(0), pair(1))
Next

Me.lblResults.Text &= strval.Item("RESULT")

Note: "&"c is a char literal, while "&" is a string literal, String.Split
expects a Char parameter. Option Strict On will complain about passing a
String literal to a Char parameter...

Hope this helps
Jay

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
|I have a string that is in the format of a url query string, but it is not
a
| query string.
| "RESULT=126&PNREF=V54A0A779FD7&RESPMSG=Under review by Fraud
| ice&AUTHCODE=422PNI&AVSADDR=N&AVSZIP=N&IAVS=N&PREF PSMSG=Review"
| It's a return from verisign
|
| What is the easiest way to split this up into string collection?
| of type stringcollection so that i can get to the value pairs?
|
| there has to be an easy way t odo this
| --
| thanks (as always)
| some day i''m gona pay this forum back for all the help i''m getting
| kes
Nov 21 '05 #5
thanks I was looking for a way to do that.
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Jay B. Harlow [MVP - Outlook]" wrote:
Kes,
The only change I would make to your & Cor's code is to only do the
s.Split("=") once:

Dim strval As New System.Collections.Specialized.NameValueCollection
Dim rsp() As String = responseout.Split("&"c)
For Each s As String In rsp
Dim pair() As String = s.Split("="c)
strval.Add(pair(0), pair(1))
Next

Me.lblResults.Text &= strval.Item("RESULT")

Note: "&"c is a char literal, while "&" is a string literal, String.Split
expects a Char parameter. Option Strict On will complain about passing a
String literal to a Char parameter...

Hope this helps
Jay

"WebBuilder451" <We***********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
|I have a string that is in the format of a url query string, but it is not
a
| query string.
| "RESULT=126&PNREF=V54A0A779FD7&RESPMSG=Under review by Fraud
| ice&AUTHCODE=422PNI&AVSADDR=N&AVSZIP=N&IAVS=N&PREF PSMSG=Review"
| It's a return from verisign
|
| What is the easiest way to split this up into string collection?
| of type stringcollection so that i can get to the value pairs?
|
| there has to be an easy way t odo this
| --
| thanks (as always)
| some day i''m gona pay this forum back for all the help i''m getting
| kes

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: cppdev | last post by:
Hi All! I want to clear the string contents from sensitive information such as passwords, and etc. It's always a case that password will appear as string at some point or another. And i feel...
5
by: SpotNet | last post by:
Hello NewsGroup, I have a custom class and a collection for that custom class that inherits CollectionBase. As such; public class MyClass { private string datamember1 = string.Empty,...
2
by: Pete Nelson | last post by:
Does anyone know of a way to bind a string collection to a datagrid? Basically, I have an object, CreditPlans, and a string collection, ModelNumbers. I'd like to bind the ModelNumbers collection...
9
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
3
by: Shimon Sim | last post by:
I have control. One of the properties is implemented as StringCollection. I didn't use any Editor attribute for it. During Design time system shows dialog similar to Items in DropDownList but Add...
5
by: deko | last post by:
Is there an accepted or standard way to get a unique name given a string and the collection in which it needs to be unique? Should I use a HashTable? Other options? Here's a first crack: ...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
2
by: michelqa | last post by:
Hi, I'm trying to display a list of string in the string collection editor just like the "items" property of an ListBox in VS IDE.... I can find many examples on the net but I cant find any...
0
by: michelqa | last post by:
I'm looking for a way to display a string collection where each element of the collection have some properties. By example : MyCollectionItem0 MyPropertyA MyPropertyB MCollectionItem1...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.