CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Posts
    10

    Red face Storing strings in dynamic array

    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?

  2. #2
    Join Date
    Feb 2005
    Posts
    23

    Arrow Re: Storing strings in dynamic array

    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.

  3. #3
    Join Date
    Sep 2003
    Posts
    10

    Re: Storing strings in dynamic array

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

  4. #4
    Join Date
    Nov 2004
    Location
    Silverdale, WA, USA
    Posts
    27

    Re: Storing strings in dynamic array

    What about using an arrayList? Code would look something like:

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

  5. #5
    Join Date
    Sep 2003
    Posts
    10

    Re: Storing strings in dynamic array

    Yes, that works, thanks. I

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured