Is it possibe to loop one form

bbelect

Member
Joined
Apr 20, 2007
Messages
14
Programming Experience
1-3
Is it possible to loop a form multiple times based on a number from a user.

Say a user enters a number in a textbox in form1 which will determine the amount of times the form2 will be displayed each time after a next button is clicked.

So i enter 2 in form1 click a button that will display form2 in form2 is a next button so if i click the next button form2 will be displayed with empty data.

Now lets say i have a textbox in form2 and want to save the value entered each time in form2 how would i do this.

I know if i say in a the next button click event

dim f2 as new Form2
f2.display()

but how do i save the values?

Thanks
 
Last edited:
Actually its possible. Try this code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ctr As Integer = 0
Dim form(10) As Form

form(ctr) = New Form
form(ctr).Show()
ctr = ctr + 1

End Sub
Your problem now is the length of the form's array. What is vague about your question is what value you want to save?
 
A Static variable will keep its value

A Static variable stays in memory for the life of the project run. Instead of Dim, use the Static keyword. Place this code in your Next button. Every time it gets clicked, it will increment the counter and keep that number in memory.


Static count As Integer
count += 1
 
Back
Top