Connecting Tech Pros Worldwide Forums | Help | Site Map

Changing pictures and playing MIDI files

Newbie
 
Join Date: Nov 2007
Location: Arizona
Posts: 9
#1: Nov 23 '07
Newbie to VB6, comfortable with HTML, MS Access so I ain't totally stupid. Maybe just dumb.

Am writing a Biblical Quiz program where I need to change a picture and midi sound file each time a user advances to a new question.

Have played with several routines but none seem to do what I want.

The following will show the first picture, on click shows the second picture, on the next click shows the third picture. Each click thereafter just rotates between pics 2 and 3. I have 9 pictures that need to be rotated or randomly sellected on each NEXT Question sellection.

This structure should do, but can not figure out how to change Picture2.Picture with either rotating or random method.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3. 'Description: Displays a two frame animation using a timer
  4. 'Place code in timer and set interval as needed
  5.  
  6. Static Choice As Integer
  7. 'Uses 3 picture boxes.
  8. 'Picture1 - visible display   Picture2&3 - pictures
  9. If Choice Then
  10.     Picture1.Picture = Picture2.Picture
  11. Else
  12.     Picture1.Picture = Picture3.Picture
  13. End If
  14.  
  15. Choice = Not Choice
  16.  
  17. End Sub
Next stupid question - What does the "." do in a command ?

Also any URL's for good "Dummy - Dummy's for VB6"

At least I did get one function to work correctly, I have an animated dove that was too lazy to flap his wing when flying across the screen. Of course VB6 doesn't see animated GIF's, so got this one figured out by extracting the 15 individual GIF pictures and using the following routine he does fly across as I want him to do.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Timer3_Timer()
  4.     picAnimate.Top = 1 'set location from top of screen
  5.  
  6. 'Static variables keep there value with each procedure call
  7.  Static currentpic As Integer
  8.  
  9.     'Determines if the animation is at the last picture and starts
  10.     'at the beginning if so
  11.     If currentpic = 14 Then currentpic = -1
  12.  
  13.     'moves to the next picture
  14.     currentpic = currentpic + 1
  15.  
  16.     'moves the picture to the left
  17.     picAnimate.Left = picAnimate.Left + 55 'orig setting 400
  18.  
  19.     'determines if image is off screen
  20.     '-3600's causes a slight delay in the animation coming back around
  21.     If (picAnimate.Left) > ScaleWidth Then picAnimate.Left = -1000 ' orig -3600
  22.  
  23.     'changes the image to the new image
  24.     picAnimate.Picture = imgDove(currentpic).Picture
  25.  
  26. End Sub
Thanks for any assistance.

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#2: Nov 29 '07

re: Changing pictures and playing MIDI files


Quote:

Originally Posted by larystoy

...I have 9 pictures that need to be rotated or randomly sellected on each NEXT Question sellection.

Put the images into a control array of Image or Picturebox controls. Then use a random number as the index to pick them up from the array.

Quote:

Originally Posted by larystoy

Next stupid question - What does the "." do in a command ?

Can you explain what you mean by that question?

You will encounter a lot of dots being used as delimiters between parts of a property or variable name. For example, Textbox1.Text refers to the Textbox1 control, Text property.[/quote]

Quote:

Originally Posted by larystoy

Also any URL's for good "Dummy - Dummy's for VB6"

No idea.


Quote:

Originally Posted by larystoy

At least I did get one function to work correctly, I have an animated dove that was too lazy to flap his wing when flying across the screen.

Yo umight check out the animation control, to see whether it's appropriate for your situation. I think you would need to convert the animation to AVI format, though.

And of course there are ways to get VB to display an animated GIF, though I can't remember them right now.
Reply


Similar Visual Basic 4 / 5 / 6 bytes