iNET Interactive - Online Advertising Agency
          
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > Using multi pictures with timer function?


Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2004, 08:43 AM
pityocamptes pityocamptes is offline
Centurion
 
Join Date: Mar 2004
Posts: 177
Default Using multi pictures with timer function?

Hi. I've been working on a small project and wanted to display 26 pictures every three seconds (for example: picture one diplays for three seconds, disappears, then pic two does likewise, wanted to keep looping all 26 pics until application is terminated). I have 26 pic boxes that are arrayed (picA(0) to picA(25)). I have tried different methods in the timer function but I cannot seem to accomplish my goal. Could someone be kind enough to pass on some simple code that will allow what I'm trying to do happen? Thanks a bunch!
Reply With Quote
  #2  
Old 03-01-2004, 09:06 AM
Aquila's Avatar
Aquila Aquila is offline
Contributor
 
Join Date: Oct 2002
Location: Ocala, Fl.
Posts: 597
Default

Quote:
Originally Posted by pityocamptes
Hi. I've been working on a small project and wanted to display 26 pictures every three seconds (for example: picture one diplays for three seconds, disappears, then pic two does likewise, wanted to keep looping all 26 pics until application is terminated). I have 26 pic boxes that are arrayed (picA(0) to picA(25)). I have tried different methods in the timer function but I cannot seem to accomplish my goal. Could someone be kind enough to pass on some simple code that will allow what I'm trying to do happen? Thanks a bunch!




Place an extra picture box on your form, as well as a timer set for interval 3000

Code:
dim m_lngLoopNumber as long private sub form_load() m_lngLoopNumber = 1 end sub private sub tmrFoo_Timer picShowPicture.picture = pica(m_lngLoopNumber).picture m_lngLoopNumber = ubound(pica) -1 then m_lngLoopNumber = 1 else m_lngLoopNumber = m_lngLoopNumber + 1 end if doevents end sub
__________________
Plotting to take over the world since 1978
Reply With Quote
  #3  
Old 03-01-2004, 09:45 AM
pityocamptes pityocamptes is offline
Centurion
 
Join Date: Mar 2004
Posts: 177
Default

Quote:
Originally Posted by Aquila
Quote:
Originally Posted by pityocamptes
Hi. I've been working on a small project and wanted to display 26 pictures every three seconds (for example: picture one diplays for three seconds, disappears, then pic two does likewise, wanted to keep looping all 26 pics until application is terminated). I have 26 pic boxes that are arrayed (picA(0) to picA(25)). I have tried different methods in the timer function but I cannot seem to accomplish my goal. Could someone be kind enough to pass on some simple code that will allow what I'm trying to do happen? Thanks a bunch!




Place an extra picture box on your form, as well as a timer set for interval 3000

Code:
dim m_lngLoopNumber as long private sub form_load() m_lngLoopNumber = 1 end sub private sub tmrFoo_Timer picShowPicture.picture = pica(m_lngLoopNumber).picture m_lngLoopNumber = ubound(pica) -1 then m_lngLoopNumber = 1 else m_lngLoopNumber = m_lngLoopNumber + 1 end if doevents end sub





Thanks again. I added a new picture (picShowPicture) and included the code you provided. However, when I run it now the UBound portion is highlighted and a compile error msg of "expected array" displays. Any ideas? Thanks again.


Code:
Private Sub tmrPicture_Timer() 'sets picture loop picShowPicture.Picture = picA(lngLoopNumber).Picture If lngLoopNumber = UBound(picA) - 1 Then lngLoopNumber = 1 Else lngLoopNumber = lngLoopNumber + 1 End If DoEvents End Sub
Reply With Quote
  #4  
Old 03-01-2004, 10:06 AM
pityocamptes pityocamptes is offline
Centurion
 
Join Date: Mar 2004
Posts: 177
Default

Thanks for your help. I figuered out my mistake and it works perfectly !!!
Reply With Quote
  #5  
Old 03-05-2004, 01:24 PM
spike4366 spike4366 is offline
Newcomer
 
Join Date: Feb 2004
Posts: 23
Default

Quote:
Originally Posted by pityocamptes
Thanks for your help. I figuered out my mistake and it works perfectly !!!


can you show me your code for the project cause i'm trying to do the same thing and my pic box is named piccornfed do i have a seperate picture box for each picture or do i just have 2 pic boxs and 1 timer
Reply With Quote
  #6  
Old 03-05-2004, 08:11 PM
passel's Avatar
passel passel is offline
Sinecure Expert
Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 6,640
Default

In case you want to display the indiviual pictures in their respective pictureboxes
(so that you could position them around the form for variety, or over top of
each other, if so desired). You can just set one of them visible at a time.

This simple code will cycle through however many pictures you have in the
control array. Change the name of the control to your control's name, of course.

Code:
 
Dim p As Long
 
Private Sub Form_Load()
Dim i As Long
Picture1(0).Visible = True 'show the first picture
For i = 1 To Picture1.UBound 'leave picture(0) visible, hide all the others
	Picture1(i).Visible = False 
Next
Timer1.Interval = 3000 '3 seconds
Timer1.Enabled = True
End Sub
 
Private Sub Timer1_Timer()
Picture1(p).Visible = False 'Hide the currently showing picture
p = (p + 1) Mod (Picture1.UBound + 1) 'select the next picture (mod will wrap back to 0)
Picture1(p).Visible = True 'Show the new picture
End Sub
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel : 03-05-2004 at 08:22 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding the handle of a combo-box list. meteo API 4 02-20-2004 11:20 AM
need help! i'm a beginner geekool General 7 04-26-2003 12:44 AM
Shareware Registry Protection Technigue karachi999 General 2 01-21-2002 02:40 PM
MS Winsocket gibson General 3 07-20-2001 10:03 AM
link function to textboxes golash General 2 05-03-2001 11:57 AM

Advertisement: