Results 1 to 4 of 4

Thread: how can i generate random pictures?

  1. #1

    Thread Starter
    Member ariel_au's Avatar
    Join Date
    Mar 2001
    Posts
    48
    i am currently working a game. i draw out imageboxes named "imgControl" (using index property) in a form.
    my problem is how can i generate random picked pictures that are stored in a folder and display them in the imgControl during run-time? (by the way the random pictures must be picked up twice) e.g: picA picA, picD, picD.

  2. #2
    Guest
    How about adding them all to a ListBox, then randomly selecting a ListIndex from the listbox will result in randomly selecting a Picture.
    Code:
    Randomize
    Num = Int(Rnd * List1.ListCount)
    
    imgControl = LoadPicture(App.Path & "\" & List1.List(Num)

  3. #3

    Thread Starter
    Member ariel_au's Avatar
    Join Date
    Mar 2001
    Posts
    48
    i only wanted the pictures stored in a folder, how can i random pick them from folder?

  4. #4
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Name them in an arithmetic sequence (e.g. {im1, im2, im3, ...}) and

    Code:
    Randomize
    Num = Int(Rnd * Number of Images you have)
    
    imgControl = LoadPicture(App.path & "Im" & Num & ".gif")
    Replace Im and .gif with whatever name/extension you gave the images.

    [Comment - Megatron: You need to get VB6]


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

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