CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2001
    Posts
    44

    how can i generate random pictures?

    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? (by the way the random pictures must be picked up twice) e.g: picA picA, picD, picD.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: how can i generate random pictures?

    name you pictures pic1.bmp, pic2.bmp, etc, say upto pic10.bmp. Then in your code,


    for i= 1 to 10
    num = 1 + int(rnd*10)
    filepath = app.path & "\pic" & num & ".bmp"
    imgControl.Picture = LoadPicture (filepath)
    imgControlAnother.Picture = LoadPicture(filepath)
    next





  3. #3
    Join Date
    Mar 2001
    Posts
    44

    Re: how can i generate random pictures?

    lets say my pic1.bmp to pic10.bmp are stored in location " C:\myfolders\picXX.bmp".

    where shall i put in the "C:\myfolders\.."??

    and if i am not wrong, u are including another imagebox called "imgControlAnother" right?



  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: how can i generate random pictures?

    filepath = "C:\myfolder" & "\pic" & num &".bmp"

    Yes, you wanted the same file to be used twice, didn't you? I was just trying to show that you can use it as many times, and in any way you like.


  5. #5
    Join Date
    Mar 2001
    Posts
    44

    Re: how can i generate random pictures?

    thank you,

    well, i draw imgControl using loops and imgControl index property is set 0.
    i just wanted to random place pictures in imgControl provided that the pics must appear twice.

    i am trying to attach my form here and try if i am able to do that...seems like i can't attach my program here. how can i attach my program here?? ( i am using "micosoft internet explorer")


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

Featured