Results 1 to 10 of 10

Thread: Showing a picture

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    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?

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    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

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    Lively Member bren0098's Avatar
    Join Date
    Jul 2005
    Posts
    67

    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.

  6. #6
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,910

    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...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  7. #7
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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.
    Doctor Ed

  8. #8
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,910

    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...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Event's Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Bar | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  9. #9

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    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

  10. #10
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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.
    Doctor Ed

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width