Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Array of values in 1 textbox

I'm having problems with a piece of code.
The form has two controls:
*Text Box
*Submit button

Users should be able to enter multiple lines in the textbox (this is
enabled) and each line is entered into a new row.

The code seems stuck in this section:
Dim mediaArray() As String
Dim count As Integer
Dim start As Integer
count = Split(txtMedia.Value, vbNewLine)
ReDim mediaArray(count) As String
mediaArray = txtMedia.Value

What am I doing wrong?

-Justin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Array of values in 1 textbox

not sure what you're trying to do, but this worked for me

Private Sub TextBox1_Change()
Dim mediaArray() As String
Dim i As Long
mediaArray = Split(textbox1.Value, vbNewLine)
For i = LBound(mediaArray) To UBound(mediaArray)
Debug.Print mediaArray(i)
Next
End Sub

--


Gary


"Justin" wrote in message
ups.com...
I'm having problems with a piece of code.
The form has two controls:
*Text Box
*Submit button

Users should be able to enter multiple lines in the textbox (this is
enabled) and each line is entered into a new row.

The code seems stuck in this section:
Dim mediaArray() As String
Dim count As Integer
Dim start As Integer
count = Split(txtMedia.Value, vbNewLine)
ReDim mediaArray(count) As String
mediaArray = txtMedia.Value

What am I doing wrong?

-Justin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Array of values in 1 textbox

I am trying to get the end result to be
row 1: name 1
row 2: name 2
row 3: name 3

from 1 textbox where the input is:
name 1
name 2
name 3

Gary Keramidas wrote:
not sure what you're trying to do, but this worked for me

Private Sub TextBox1_Change()
Dim mediaArray() As String
Dim i As Long
mediaArray = Split(textbox1.Value, vbNewLine)
For i = LBound(mediaArray) To UBound(mediaArray)
Debug.Print mediaArray(i)
Next
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Array of values in 1 textbox

Justine

Another way to do it is to have three text boxes in the form and don't have
multi line.

It is easier than having people mess with multi line text boxes.

--
Hope this helps
Martin Fishlock


"Justin" wrote:

I am trying to get the end result to be
row 1: name 1
row 2: name 2
row 3: name 3

from 1 textbox where the input is:
name 1
name 2
name 3

Gary Keramidas wrote:
not sure what you're trying to do, but this worked for me

Private Sub TextBox1_Change()
Dim mediaArray() As String
Dim i As Long
mediaArray = Split(textbox1.Value, vbNewLine)
For i = LBound(mediaArray) To UBound(mediaArray)
Debug.Print mediaArray(i)
Next
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Array of values in 1 textbox

It doesn't quite work because we don't know how many entries we will
need. For example, we could have 15 one time, and 2 the next. The
dynamic nature of the problem necesitates trusting the user a bit.
Martin Fishlock wrote:
Justine

Another way to do it is to have three text boxes in the form and don't have
multi line.

It is easier than having people mess with multi line text boxes.

--
Hope this helps
Martin Fishlock


"Justin" wrote:

I am trying to get the end result to be
row 1: name 1
row 2: name 2
row 3: name 3

from 1 textbox where the input is:
name 1
name 2
name 3

Gary Keramidas wrote:
not sure what you're trying to do, but this worked for me

Private Sub TextBox1_Change()
Dim mediaArray() As String
Dim i As Long
mediaArray = Split(textbox1.Value, vbNewLine)
For i = LBound(mediaArray) To UBound(mediaArray)
Debug.Print mediaArray(i)
Next
End Sub








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
Set Textbox value = large(ARRAY,k) BlueWolverine Charts and Charting in Excel 1 July 29th 09 05:03 PM
Array: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 4 April 16th 07 03:12 AM
How do I add TextBox.values? WTG Excel Programming 4 February 28th 05 09:38 AM
How do I add TextBox.values? WTG Excel Discussion (Misc queries) 1 February 27th 05 08:25 PM
How do I add TextBox.values? WTG Excel Worksheet Functions 1 February 27th 05 08:22 PM


All times are GMT +1. The time now is 12:07 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"