-
Showing a picture
Hi friends,
I have 6 pictures. I want some of them appear on the form by clicking command button.
The important point is the same pictures won't appear in each click.
For example,
First click, picture-1, picture-2, picture-3, picture-4 will appear
Second click, picture-3, picture-2, picture-5, picture-6 will appear
Third click picture-4, picture-5, picture-6, picture-1 will appear
etc...
How can I do this?
-
Re: Showing a picture
One option.
1. Declare a form-level variable at top of your form, i.e., intClickCount As Integer
2. In your button's click event something like this
Code:
Select Case intClickCount
Case 0 ' first click
intClickCount = intClickCount + 1
show pictures 1,2,3,4
Case 1 ' 2nd click
intClickCount = intClickCount + 1
show pictures 3,2,5,6
Case 2 ' 3rd click
intClickCount = 0 ' reset so we start over again on next click
show pictures 4,5,6,1
End Select
-
Re: Showing a picture
Thanks for reply but it isn't what I meant. There is a programme which will show the pictures. First time, I ran the programme. It showed 1 2 3 4 pictures, after that I closed the programme. When I ran the programme again, it will show different pictures, for example: 3 5 2 6 pictures or anything else. It doesn't matter. I want it to change the pictures, which will appear, in each running the programme
-
Re: Showing a picture
In that case, you want to store settings outside the program. This can be in an INI file, a database, the registry, etc. In the FAQ section, linked in my signature below, you can find examples of INI file usage
-
Re: Showing a picture
If the amount of pictures on your form will be static, then create a random array that will effectively mix up the picture every time you click the button.
-
Re: Showing a picture
-- Question #1: Where are these Bitmaps stored??? Are they on a local disk, network disk, remote disk or even a resource file. I had the source code for a Bitmap to be shown by Resource File, but losted the code. It's only a one liner, as well...
-- Question #2: Is this some sort of Animation sequence. If so, then create the animation in the Microsoft Windows Video Editor, that comes with Windows XP SP3!!
Then that's the hard work taken out of the programming side of things...
-
Re: Showing a picture
Sounds like all he needs is a random sequence of 4 image files selected from a list of 6. The image controls then load in 4 different images selected from 6 available files with no duplicates whenever a command button is pressed.
OP, please correct me if I am wrong. :ehh:
-
Re: Showing a picture
Then setup a animated gif with all of the different types, and then make a call to show rather one of them, at an interval of one second, or smaller than that??? That was much like what I was doing, in Video Editor for Windows XP SP3...
-
Re: Showing a picture
LaVolpe ,
I want the programme to show different pictures when I run the programme. Do I need to know to do this?
bren0098,
How can I do this? Could you give an example?
ThEiMp,
Answer1, They are on my hard disc
Answer2, They are pictures not animations
Code Doc,
Yes you're right I want it to happen randomly.
ThEiMp,
Animation isn't what I want.
Thanks for replies
-
Re: Showing a picture
This should help get you started. Here's some code. Build four image controls in a control array (0 to 3).
Code:
Dim PicArray() As Integer
Const NumPics = 6
Private Sub Command1_Click()
'Shuffle PicArray
Dim iMin As Integer, iMax As Integer, Temp As Integer, varSwap As Integer
iMin = 1
iMax = NumPics
For i = iMax To iMin + 1 Step -1
Temp = Int((i - iMin + 1) * Rnd + iMin)
varSwap = PicArray(i)
PicArray(i) = PicArray(Temp)
PicArray(Temp) = varSwap
Next
' Suppose your 6 image files are named "Pic1.jpg", "Pic2.Jpg", etc.
' Select the first 4 integers in the shuffled array
For i = iMin To 4
Image1(i - 1).LoadPicture "" ' Clears the control
Image1(i - 1).LoadPicture "Pic" & Format$(PicArray(i), "&") & ".Jpg"
Next
End Sub
Private Sub Form_Load()
ReDim PicArray(NumPics)
For i = 1 To 6
PicArray(i) = i
Next
Randomize
End Sub
Each time you click the command button, a random selection of 4 images from your 6 files will be loaded into the image controls. I haven't tested this completely, but I believe it's time for you to take over.