1.

Solve : In VB-6 to put text boxes data in a array?

Answer»

Sir,
In VB-6 application, there are 15 text boxes and these get data from mdb FILE. I want to use the data of these text boxes in a array, how can I ?
Example
            text1.text=100, text2.text=200 and so on upto text15.text
           Dim test(15),
To put these value in a array
           for i = 1 to 15 
                 test(i)=val(text(i).text))  ' so that test(i) may contain data of text1.text
           next
This is not working, why? Please TELL me reason or solutioncreate a control array.

Or you COULD create a property procedure in your form, for example:

Code: [Select]Public Property Tbox(Byval Index as Long) as TextBox
if index=1 then set TBox = Text1
if index=2 then set TBox = Text2
if index=3 then set TBox = Text3
 ' and so on...

End Property

a Control array is created by copy-pasting the same control, or a control with the same name as a control on the form.
Sir,
In reference to my querry, what has been suggested still carry on my problem ie I do not want to use text1 or text2 . In place of it, I want to input data through Loop
         for i = 1 to 15 
                 test(i)=val(text(i).text))  ' so that test(i) may contain data of text1.text
           next
My purpose is to minimise my code, If I have to use 50 text boxes then ? will I have3 to write 50 lines ?
Please solve my problem this way.use control arrays. It's your problem, not mine, remember?


Set the Index property on the textboxes and give them the same Name.My dear friend,

what you mean by Remember? or it is your problem not mine.

I had not COMPELLED you to solve my problem. I know solution of my problem but in a lengthy way. If you cann't solve my problem in shorter way, you need not to answer but not in a such a way.
Use a control array. I already said this. this is what you need to do.



Discussion

No Comment Found