PC Review


Reply
Thread Tools Rate Thread

Array of values in 1 textbox

 
 
Justin
Guest
Posts: n/a
 
      26th Nov 2006
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

 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      26th Nov 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Justin
Guest
Posts: n/a
 
      26th Nov 2006
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 With Quote
 
=?Utf-8?B?TWFydGluIEZpc2hsb2Nr?=
Guest
Posts: n/a
 
      26th Nov 2006
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 With Quote
 
Justin
Guest
Posts: n/a
 
      30th Nov 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox to Array, Array Displayed in Textbox Derrick Candler Microsoft VB .NET 0 25th Sep 2011 09:08 AM
Array: Counting multiple values within array Trilux_nogo Microsoft Excel Worksheet Functions 4 16th Apr 2007 03:12 AM
search an array for values contained in another array =?Utf-8?B?Q2hlZXItUGhpbC1seQ==?= Microsoft Excel Programming 0 12th Apr 2007 09:44 PM
Create array of Textbox Dynamically and retrieve data from that textbox in asp .net Raju Microsoft C# .NET 1 8th Feb 2006 02:33 PM
Create array of Textbox Dynamically and retrieve data from that textbox in asp .net Raju Microsoft C# .NET 0 8th Feb 2006 06:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:40 PM.