Click to See Complete Forum and Search --> : Storing strings in dynamic array


chickensteam
February 4th, 2005, 03:04 PM
I want to store a list of integers that are entered in a number of text boxes and comboboxes as a string in an array. Ech time someone clicks the 'Purchase' button these integers (representing the code, quantity etc. of an item bought) will be listed as a string and held in an array. The textboxes etc. will then be cleared for the next set of data.

At the top of the code window I've declared:
Dim ValArray() as integer

In the click event of the purchase button The code relating to the string and array is as follows so far:

Dim Values As String
Dim i As Integer

Values = txtRef.Text +CombType.text 'this continues to include all text boxes etc.

ReDim ValArray(Values - 1)
For i = 0 To UBound(ValArray)
ValArray(i) = Values
Next

That's as far as I've got. I think I've gone wrong with the last statement, can anyone point out the obvious to me?

Ch0pinZee
February 4th, 2005, 03:15 PM
It might be helpful if you posted a screenshot of your form, and explained exactly what you want to have happen on the form when the user clicks purchase. If you do this I will probably for sure be able to help you.

chickensteam
February 7th, 2005, 03:01 PM
Hi,

Please see attached image of form.

When the purchase button is pressed the numbers entered in the various boxes are listed in string format and stored in the array eg. the six figure ref no and the type code (1-4) would be 1234563. All the boxes will then be cleared for the next set of info to be entered.

The info will be used to generate a sales report later on in the program.

jeremiah98383
February 7th, 2005, 05:21 PM
What about using an arrayList? Code would look something like:

dim purchases as new arraylist

'then on each purchase click
dim values as string
Values = txtRef.Text +CombType.text 'this continues to include all text boxes etc.
purchases.add(values)
Hope I understood what you were looking for.

chickensteam
April 14th, 2005, 02:06 PM
Yes, that works, thanks. I

've just come back to this after working on other stuff.