By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

changing pictures

P: 4
i have a splash screen that i want to change a picture once a second for three seconds; then load my main form. what i want it to do is load a picture into a picture box; start a timer which will stop the loop for one second then start the loop again add 1 to the pintcount which will result in the name of aneither picture (my pictures are named 1, 2, 3) i have it in the form load event procedure. this is the code that i have so far. what i have tried to do is put this code in the timer 1 procedure and it resulted in executing the timer and when the timer finished then the code executed, so i moved it to the form load procedure. the problem that i seek help with is: how can i get the timer to execute inside of the loop, becouse without it the loop just fly's through the code and only shows the last picture


Private Sub Form_Load()

Dim pintcount As Integer
Dim pstrloc As String
Dim pstrpicname As String

pintcount = 1
pstrloc = "G:\school\vis basic\changing pictures1\pictures\"

For pintcount = 1 To 3
pstrpicname = pstrloc & pintcount & ".jpg"
Picture1.Picture = LoadPicture(pstrpicname)
Timer1.Enabled = True
Form1.Refresh
pintcount = pintcount + 1
Next

If pintcount = 3 Then
Unload Form1
End If
End Sub
Nov 15 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 267
i have a splash screen that i want to change a picture once a second for three seconds; then load my main form. what i want it to do is load a picture into a picture box; start a timer which will stop the loop for one second then start the loop again add 1 to the pintcount which will result in the name of aneither picture (my pictures are named 1, 2, 3) i have it in the form load event procedure. this is the code that i have so far. what i have tried to do is put this code in the timer 1 procedure and it resulted in executing the timer and when the timer finished then the code executed, so i moved it to the form load procedure. the problem that i seek help with is: how can i get the timer to execute inside of the loop, becouse without it the loop just fly's through the code and only shows the last picture


Private Sub Form_Load()

Dim pintcount As Integer
Dim pstrloc As String
Dim pstrpicname As String

pintcount = 1
pstrloc = "G:\school\vis basic\changing pictures1\pictures\"

For pintcount = 1 To 3
pstrpicname = pstrloc & pintcount & ".jpg"
Picture1.Picture = LoadPicture(pstrpicname)
Timer1.Enabled = True
Form1.Refresh
pintcount = pintcount + 1
Next

If pintcount = 3 Then
Unload Form1
End If
End Sub
hi
not surpised

you made a for/next loop with printcount, first declare printcount=1, add 1 to printcount in the loop where printcount is the counter and use a statement if printcount=3 outside your for/next loop
printcount will leave the for/next loop as 4

bit confusing

Private Sub Form_Load()

Dim pintcount As Integer
Dim pstrloc As String
Dim pstrpicname As String

pstrloc = "G:\school\vis basic\changing pictures1\pictures\"

For pintcount = 1 To 3
pstrpicname = pstrloc & pintcount & ".jpg"
Picture1.Picture = LoadPicture() 'to clear the picture
Picture1.Picture = LoadPicture(pstrpicname)
Timer1.Enabled = True
Form1.Refresh
Next

'if your timer will delay pictureswitch for 1 second
'then you can unload your form right after the loop

Unload Form1
End Sub
Nov 15 '06 #2

100+
P: 267
hi
not surpised

you made a for/next loop with printcount, first declare printcount=1, add 1 to printcount in the loop where printcount is the counter and use a statement if printcount=3 outside your for/next loop
printcount will leave the for/next loop as 4

bit confusing

Private Sub Form_Load()

Dim pintcount As Integer
Dim pstrloc As String
Dim pstrpicname As String

pstrloc = "G:\school\vis basic\changing pictures1\pictures\"

For pintcount = 1 To 3
pstrpicname = pstrloc & pintcount & ".jpg"
Picture1.Picture = LoadPicture() 'to clear the picture
Picture1.Picture = LoadPicture(pstrpicname)
Timer1.Enabled = True
Form1.Refresh
Next

'if your timer will delay pictureswitch for 1 second
'then you can unload your form right after the loop

Unload Form1
End Sub
hi sry forgot the timerdelay
instead of using a timer, you may use

start=Timer : While Timer<start+1: DoEvents : Wend

just after loading the new picture
it's a non-elagant way of delay, but it works
Nov 15 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.