Thanks for all the replies below. I ended up looping thru the data and
using the split function on the vbNewLine of the string. As you can see
below, the string has 4 or 5 vbNewLine(s). The string is parsed into an
array of 5 strings so I wrote some code to split the 2 parameters out of
each string by searching or spaces or vbTab, then trimming the data on each
side of the space or vbTab.
As for performance, its not an issue here since there might only be 20 line
items to parse out. But often I do data cleansing and one time I wrote
several regular expressions to help parse parameters out of 15000+ lines of
text and that took minutes to run, where as I wrote something similar in vba
years ago and took about 10 seconds to run through just as much data. So the
vba was more code to write and ran faster, but in the recent example, I
don't know if I could have written vb.net code to do the same kind of
sophisticated parsing regex did.
Thanks for the comments.
--
mo*******@nospam.com
"Cor Ligthert" <no************@planet.nl> wrote in message
news:eF**************@TK2MSFTNGP14.phx.gbl...
Moondaddy,
It is known by most regulars in this newsgroup that I do not like the
Regex. Think about it that is at least (for simple problems) about 20 times
slower than a normal loop and replace function.
So I would use for your problem something as (not tested)
\\\
For each st as string in myrows
st = "param1=" & st
st = st.replace(" "," param2=")
next
///
I hope this helps?
Cor
"moondaddy"
I'm writing an app in vb.net 1.1 and I need to parse strings that look
similar to the one below. All 5 rows will make up one string. I have a
form where a use can copy/paste data like what you see below from excel,
word, notepad, etc.. into a textbox on my form. I need to break each
line into 2 numbers which I'll use as parameters for another function. in
all cases each line will be separated with a vbNewline and in most cases the
2 numbers in the line (2483 and 21 for example) will be separate be a tab
space, but I cant guarantee that. It should however be some sort of
white space in-between the 2 numbers. I could split the string below into 5
smaller strings, but I'm short on a reliable way to consistently parse
the 2
numbers from each string.
2483 21
2484 23
24853 3
2486 14
2487 5
the end result of what I want to do is parse this string where I can
feed each value into parameters like this
param1=2483 param2=21
param1=2484 param2=23
param1=24853 param2=3
param1=2486 param2=14
param1=2487 param2=5
any good recommendations?
Thanks
--
mo*******@nospam.com