By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

Pasting multiple lines of data into text box - how do I divide it into seperate strings??

P: n/a
I've got a text box that I want users to paste a list of values into
(from Excel for example). However, breaking this large string down into
its component records is a little harder. I've used left(), mid() etc
but they depend on a set number of characters for each line. I'm
wondering if there is an operator which detects the new line and so
would allow me to icut each line and put it into an array.

Also wonding if there is a setting in text boxs which allows a user to
press 'enter' and go to a new line instead of to the next field.

Cheers

Reg

Dec 7 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Sorted the new line thing - ctrl enter.... simple I know.

Dec 7 '05 #2

P: n/a
The easiest way to split the input is to use the Split function

Something like:-

Dim varArray as variant
dim intCount as integer

varArray = Split(me.txtInput, vbCrLf)

If IsArray(varArray) then
for intCount = lBound(varArray) to uBound(varArray)
' do stuff with the individual lines
next
end if

--
Terry Kreft

"Regnab" <p.*******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I've got a text box that I want users to paste a list of values into
(from Excel for example). However, breaking this large string down into
its component records is a little harder. I've used left(), mid() etc
but they depend on a set number of characters for each line. I'm
wondering if there is an operator which detects the new line and so
would allow me to icut each line and put it into an array.

Also wonding if there is a setting in text boxs which allows a user to
press 'enter' and go to a new line instead of to the next field.

Cheers

Reg

Dec 7 '05 #3

P: n/a
Setting the form control property "Enter Key Behavior" to "New Line In
Field" will cause 'Enter' to go to a new line

"Regnab" <p.*******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I've got a text box that I want users to paste a list of values into
(from Excel for example). However, breaking this large string down into
its component records is a little harder. I've used left(), mid() etc
but they depend on a set number of characters for each line. I'm
wondering if there is an operator which detects the new line and so
would allow me to icut each line and put it into an array.

Also wonding if there is a setting in text boxs which allows a user to
press 'enter' and go to a new line instead of to the next field.

Cheers

Reg

Dec 7 '05 #4

P: n/a
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:5q********************@karoo.co.uk:
The easiest way to split the input is to use the Split function

Something like:-

Dim varArray as variant
dim intCount as integer

varArray = Split(me.txtInput, vbCrLf)

If IsArray(varArray) then
for intCount = lBound(varArray) to uBound(varArray)
' do stuff with the individual lines
next
end if


Split() was introduced only with A2K. I think that as long as A97 is
still a mainstream development platform (which it certainly is), one
should mention this with features that were introduced only in later
versions of Access.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 8 '05 #5

P: n/a
Well, for sure; I always keep a bucket of oats and a big shovel for my
friends who come to visit with the horse and buggy.

Dec 8 '05 #6

P: n/a

Well, I think that I could do that, but as it's my time I'm spending
answering the OP I think instead I'll decide how I use it.

So, if the OP states they use A97 I'll tailor the answer to that, if they
don't, and I'm in the mood, I'll answer for all versions. If I'm not in the
mood for that I'll answer for the latest version and wait for them to
respond if it doesn't work.

If I don't feel like it I won't answer at all.
--
Terry Kreft

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@216.196. 97.142...
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:5q********************@karoo.co.uk:
The easiest way to split the input is to use the Split function

Something like:-

Dim varArray as variant
dim intCount as integer

varArray = Split(me.txtInput, vbCrLf)

If IsArray(varArray) then
for intCount = lBound(varArray) to uBound(varArray)
' do stuff with the individual lines
next
end if


Split() was introduced only with A2K. I think that as long as A97 is
still a mainstream development platform (which it certainly is), one
should mention this with features that were introduced only in later
versions of Access.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Dec 8 '05 #7

P: n/a
Well let me just say that I'm very glad you were in the mood (very
helpful for me), I'm using Access 2003, and I thoroughly enjoyed the
verbal sparring....

Dec 8 '05 #8

P: n/a
Your code works a treat. Brilliant. Thanks Terry.... you tailored it
rather nicely....

Dec 8 '05 #9

P: n/a
Terry Kreft wrote:
The easiest way to split the input is to use the Split function

Something like:-

Dim varArray as variant
dim intCount as integer

varArray = Split(me.txtInput, vbCrLf)

If IsArray(varArray) then
for intCount = lBound(varArray) to uBound(varArray)
' do stuff with the individual lines
next
end if


I hadn't heard of split. Thanks for bringing it to Regnab's and my
attention, though I wish I'd known about it previously... good heavens,
would have saved me a large amount of time I spent recently some parsing
procs!!! 8)

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Dec 8 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.