Panels

vbnoob

Member
Joined
Mar 3, 2005
Messages
11
Programming Experience
1-3
hi am quite new to vb and i need a lil help

basically i need to refresh a panel in my form everytime a button is pressed and a counter indicating the number of times the button has been pushed

i use the following

panel.refresh()

counter += 1
textbox.text = counter

but it only does it once!!

Secondly on the same form i need to have a panel to become visible every 2 minutes remain visible for 1 min n vanish i need to do this for 10 mins

currently i have this

Dim i As Integer

Dim limit As Integer

limit = Int(Rnd() * 10)

If limit = 3 Or limit = 5 Then

For i = 1 To 50

Panel2.Visible =
True

Next i

Else

Panel2.Visible = False

End If

but obviously it anit workin!!
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Where did you put your refresh code? It should be in the buttons onclick event.

You want to add a timer to your project, set the interval to 1 min and enable it.
Then make a global numberof ticks. In the tick event of the timer +1 to the global #of ticks, and using the # of ticks work out if panel 2 should be visable or not, and at the end check to see if # of ticks = 10 - if it is disable the timer.

TPM
 

NPToita

New member
Joined
Mar 3, 2005
Messages
3
Programming Experience
3-5
First of the counter variable:
1) you can declare as a field variable
2) you can make it as a static variable inside the button's click event.

secondly and lastly, you're trying make the panel2 visible whenever your limit is 3 or 5. You don't have to tell the computer to make panel2 visible 50 times in a row, once is enough; you don't want others to tell you what to do over and over again 50 times with in 1 minute do you? in this case you don't need random, but instead you need a timer control. Let's see, you have 10 minutes. Start out with 2minutes invisible, then 1 minute visible; that's a total of 3 minutes each round. So your panel will appear 3 times and will never show up again. This also means your timer will be on/off 6 times. First, create a static counter and set it to 1. Then, start with the timer control 2 minutes interval, using the design. In the timer's tick event, make the panel visible, stop the timer, change timer's interval to 1 minute, and start the timer again, and increase the counter by 1 whenever the counter is odd, then increase the timer. When the timer is even, make panel invisible, stop the timer, change the timer back to 2 minutes, increase the counter, and start the timer again. Lastly, disable the timer completely when the counter equals 6.

PS: I can write the code for you, but if i do that it take away all the fun from you. I always enjoy it when i could write my own codes instead of using others codes, but sometimes i do need to look at examples to know what to do. So i decided to explain to you what to do instead of writing the codes for you.
 

vbnoob

Member
Joined
Mar 3, 2005
Messages
11
Programming Experience
1-3
many thanks for the info

i understand a lil bit more now wat am doin

thanz for replying
 

vbnoob

Member
Joined
Mar 3, 2005
Messages
11
Programming Experience
1-3
1) you can declare as a field variable
2) you can make it as a static variable inside the button's click event

Sorry i dunno how to do this!!
 
Top Bottom