Save info into an Array and show this Array - Using Form (1 Viewer)

Surka

IT dude
Local time
Today, 13:00
Joined
Aug 5, 2013
Messages
41
Good day!

I want to save input into an Array, and then show this information.

To enter data I am using a textBox. After "Enter" it should save info into the Array.

If textBox is empty, it should show information. I would like to use a textbox too, that shows all the Array after pressing Enter.

textbox on the Form: txtInput, txtOutput

I have the following code, but I am not able to get it work:

Code:
Option Compare Database
 
Public Sub Form_Load()
 
Dim Data(10) As Integer
Dim i As Integer
Dim j As Integer
Dim bExit As Boolean
Const MaxElem As Integer = 10
Const MaxArray As Integer = MaxElem - 1
i = 0
j = 0
bExit = False
 
'------------------------------
'initialize array
'------------------------------
For i = 0 To 10
    Data(i) = 0
Next
i = 0
 
'------------------------------
'save data into array
'------------------------------
While ((i <= MaxArray) And (bExit = False))
    Data(i) = Me.txtInput
    i = i + 1
 
    If (Len(Me.txtInput) <> 0) Then
        bExit = True
    End If
 
Wend
 
'------------------------------
'show on textBox arrays data
'------------------------------
While j < i
    Me.txtOutput = Data(j)
    j = j + 1
 
Wend
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:00
Joined
Feb 19, 2013
Messages
16,553
I don't understand what you are trying to do - can you explain more clearly - provide some examples.

I particularly don't understand this!

If textBox is empty, it should show information. I would like to use a textbox too, that shows all the Array after pressing Enter.

Forms work with recordsets so you can't 'display' an array as such, you would need to split the array into its various elements and then show these - you could use a listbox with a value list to do this to show them vertically. Or you would split the array and then combine them into one long string to show them horizontally.
 

Surka

IT dude
Local time
Today, 13:00
Joined
Aug 5, 2013
Messages
41
Empty textBox means end of data entry.

To save information into an Array, and then work with it (use this information): what do you suggest?

Information must enter into the Array one by one, and will exit when textBox is Blank.

Thanks CJ
 

jdraw

Super Moderator
Staff member
Local time
Today, 12:00
Joined
Jan 23, 2006
Messages
15,364
Data bases store data in Tables. You could open a recordset based on a table and put the data into an array for processing. PLease tell us more about your need for an array.
 

Users who are viewing this thread

Top Bottom