Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Extract each line of text from a textbox into an array

Hi all

Please can somebody help me

[Excel 2010 on Windows 7]

I have a textbox that the user can populate by entering text and hitting
enter, creating several lines of text.
(Alternatively, she may take several lines of text from, say a webpage,
cutting and pasting it in)

Upon exiting the text box, I now would like to take each line, one at a
time, and place them into a globally dimensioned array called Features.

Private Sub TBoxFeatures_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
Dim LinesOfText As Integer
If Len(TBoxFeatures) 0 Then
LinesOfText = TBoxFeatures.LineCount
If LinesOfText 0 Then
For I = 0 To LinesOfText
Features(I) = TBoxFeatures 'XXX
Next I
End If
End If
End Sub

XXX = this is the tricky part - how to get *each row* of data into the
array - as it stands it places all lines together into each element of the
array


Thanks in advance

Peter Bircher

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract each line of text from a textbox into an array

It happens that Peter Bircher formulated :
Hi all

Please can somebody help me

[Excel 2010 on Windows 7]

I have a textbox that the user can populate by entering text and hitting
enter, creating several lines of text.
(Alternatively, she may take several lines of text from, say a webpage,
cutting and pasting it in)

Upon exiting the text box, I now would like to take each line, one at a time,
and place them into a globally dimensioned array called Features.

Private Sub TBoxFeatures_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
Dim LinesOfText As Integer
If Len(TBoxFeatures) 0 Then
LinesOfText = TBoxFeatures.LineCount
If LinesOfText 0 Then
For I = 0 To LinesOfText
Features(I) = TBoxFeatures 'XXX
Next I
End If
End If
End Sub

XXX = this is the tricky part - how to get *each row* of data into the array
- as it stands it places all lines together into each element of the array


Thanks in advance

Peter Bircher


Try changing your approach! For example...

Dim vText As Variant, n As Integer

'Load textbox contents into an array
vText = Split(TBoxFeatures.Text, vbCrLf)

For n = LBound(vText) To UBound(vText)
'process each line
Debug.Print vText(n)
Next 'n

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Extract each line of text from a textbox into an array

Thanks, Garry for that super fast reply!

I will give it a shot

Peter Bircher

"GS" wrote in message ...

It happens that Peter Bircher formulated :
Hi all

Please can somebody help me

[Excel 2010 on Windows 7]

I have a textbox that the user can populate by entering text and hitting
enter, creating several lines of text.
(Alternatively, she may take several lines of text from, say a webpage,
cutting and pasting it in)

Upon exiting the text box, I now would like to take each line, one at a
time, and place them into a globally dimensioned array called Features.

Private Sub TBoxFeatures_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
Dim LinesOfText As Integer
If Len(TBoxFeatures) 0 Then
LinesOfText = TBoxFeatures.LineCount
If LinesOfText 0 Then
For I = 0 To LinesOfText
Features(I) = TBoxFeatures 'XXX
Next I
End If
End If
End Sub

XXX = this is the tricky part - how to get *each row* of data into the
array - as it stands it places all lines together into each element of the
array


Thanks in advance

Peter Bircher


Try changing your approach! For example...

Dim vText As Variant, n As Integer

'Load textbox contents into an array
vText = Split(TBoxFeatures.Text, vbCrLf)

For n = LBound(vText) To UBound(vText)
'process each line
Debug.Print vText(n)
Next 'n

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Extract each line of text from a textbox into an array

Hi Garry

Have applied it and it works perfectly.

Thanks ever so much

Pete

"GS" wrote in message ...

It happens that Peter Bircher formulated :
Hi all

Please can somebody help me

[Excel 2010 on Windows 7]

I have a textbox that the user can populate by entering text and hitting
enter, creating several lines of text.
(Alternatively, she may take several lines of text from, say a webpage,
cutting and pasting it in)

Upon exiting the text box, I now would like to take each line, one at a
time, and place them into a globally dimensioned array called Features.

Private Sub TBoxFeatures_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim I As Integer
Dim LinesOfText As Integer
If Len(TBoxFeatures) 0 Then
LinesOfText = TBoxFeatures.LineCount
If LinesOfText 0 Then
For I = 0 To LinesOfText
Features(I) = TBoxFeatures 'XXX
Next I
End If
End If
End Sub

XXX = this is the tricky part - how to get *each row* of data into the
array - as it stands it places all lines together into each element of the
array


Thanks in advance

Peter Bircher


Try changing your approach! For example...

Dim vText As Variant, n As Integer

'Load textbox contents into an array
vText = Split(TBoxFeatures.Text, vbCrLf)

For n = LBound(vText) To UBound(vText)
'process each line
Debug.Print vText(n)
Next 'n

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract each line of text from a textbox into an array

Peter Bircher formulated the question :
Hi Garry

Have applied it and it works perfectly.

Thanks ever so much

Pete


You're welcome! ..I appreciate the feedback!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract text from a "textbox" Robert Crandal[_2_] Excel Programming 7 December 30th 10 08:03 PM
Line-by-line formatting in Excel 2007 Textbox Warcon Excel Programming 3 February 17th 09 10:26 PM
How do I extract hyperlink as text from an array of hyperlinks? Hoya Excel Worksheet Functions 8 December 29th 05 05:16 PM
Textbox-read text line by line antonio Excel Programming 0 October 26th 04 05:42 PM
how to extract text from a TextBox Jim Kalinowski Excel Programming 0 January 13th 04 08:26 PM


All times are GMT +1. The time now is 06:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"