473,379 Members | 1,539 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,379 software developers and data experts.

getting Nth position in a comma delimited string..

yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have to
use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz
Nov 21 '05 #1
7 6380
hazz,

Why not Split them and use trim on the strings?

Dim s As String = "a, b, c, d"
MsgBox(s.Split(",")(1).Trim)

HTH,

Shane Story

"hazz" <hazz@sonic_net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have
to use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz

Nov 21 '05 #2
You can just use the build in split() function i.e.
Dim myString As String = "V,-1,1,2,-1,333,5"
Dim myArray() As String = Split(myString,",")

or else use one of the overloads of the String.Split or RegEx.Split methods.

"hazz" <hazz@sonic_net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have to use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz

Nov 21 '05 #3
hazz,

Perhaps you could use a variation of:

Dim myArray() As String = Split("V,-1,1,2,-1,333,5", ",")

For Each s As String In myArray
MsgBox(s)
Next

Kerry Moorman
"hazz" wrote:
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have to
use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz

Nov 21 '05 #4
Thank you!

"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
You can just use the build in split() function i.e.
Dim myString As String = "V,-1,1,2,-1,333,5"
Dim myArray() As String = Split(myString,",")

or else use one of the overloads of the String.Split or RegEx.Split
methods.

"hazz" <hazz@sonic_net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have

to
use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz


Nov 21 '05 #5
Thank you!

"Shane Story" <no****@nothanks.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
hazz,

Why not Split them and use trim on the strings?

Dim s As String = "a, b, c, d"
MsgBox(s.Split(",")(1).Trim)

HTH,

Shane Story

"hazz" <hazz@sonic_net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have
to use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz


Nov 21 '05 #6
Thank you!

"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
hazz,

Perhaps you could use a variation of:

Dim myArray() As String = Split("V,-1,1,2,-1,333,5", ",")

For Each s As String In myArray
MsgBox(s)
Next

Kerry Moorman
"hazz" wrote:
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have
to
use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz

Nov 21 '05 #7

"Cathal Connolly [VB MVP]" <cc*******@eg-consulting.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
You can just use the build in split() function i.e.
Dim myString As String = "V,-1,1,2,-1,333,5"
Dim myArray() As String = Split(myString,",")

or else use one of the overloads of the String.Split or RegEx.Split
methods.

"hazz" <hazz@sonic_net> wrote in message
news:OC**************@TK2MSFTNGP12.phx.gbl...
yes i should know this but ...

V,-1,1,2,-1,333,5

I would like to return the value from any position within the comma
delimited string

position 1 is "v"
position 2 is "-1"
position 6 is "333"

at first I thought I could use string.chars(n) until I realized that
1. There are commas and that the spaces between the commas vary so I have

to
use an algorithm and function(s) that look for
1. the first item contained before the first comma,
2 the second item contained between the first and second comma,
3 the third item contained between the second and third,
etc.

thank you,
-hazz


Nov 21 '05 #8

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

Similar topics

4
by: Arne | last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com> Subject: Comma delimited array into DB problems Date: 9. februar 2004 10:39 Hi, I have an asp page that takes input from a form on the previous...
9
by: PaulThomas | last post by:
I want to "look" through a comma delimited String and "take it apart" by finding the comma's and then put each "set of characters" into seperate strings - - - maybe an array, maybe seperate cells...
2
by: Larry Williams | last post by:
Is there an easy way to convert a string of data to XML format without having to create the xml one field at a time? Sorry I'm a newbie and my xml knowledge is limited. I have tried to search...
22
by: argniw | last post by:
I have a table that looks like this: Forest Residents Black Josh Black Joellen Black Mary Jane Brown Gertrude Brown Josh Brown Mary Jane
9
by: Wayne | last post by:
I have the following string: "smith", "Joe", "West Palm Beach, Fl." I need to split this string based on the commas, but as you see the city state contains a comma. String.split will spilt the...
5
by: Yama | last post by:
Hi, I am looking to create a report comma delimited on a click of a button. Explanantion: 1. Get from the database: "SELECT * FROM Customers WHERE Region = 'CA'" 2. Use either DataReader or...
25
by: electrixnow | last post by:
in MS VC++ Express I need to know how to get from one comma delimited text string to many strings. from this: main_string = "onE,Two,Three , fouR,five, six " to these: string1 =...
15
by: VMI | last post by:
I'm parsing a comma-delimited record but I want it to do something if some of the string is between "". How can I do this? With the Excel import it does it correct. I'm using String.Split()....
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.