Array of values in 1 textbox

  • Thread starter Thread starter Justin
  • Start date Start date
J

Justin

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
 
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
 
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
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top