Results 1 to 3 of 3

Thread: Picture Question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking Picture Question

    The code below is suppose to randomly load one of the pictures
    in the variable computer and send it to piccpu.picture property.
    However, it is not working can someone help me and tell me what
    to add or change to make the code work properly, Thanks GOD BLESS!


    vbcode:

    Public Function Rand(ByVal Low As Long, ByVal high As Long) As Long
    Rand = Int((high - Low + 1) * Rnd) + Low
    End Function

    Sub opponent()
    Dim computer(1 To 3) As Variant
    computer(1) = LoadPicture(App.Path & "\carl.bmp")
    computer(2) = LoadPicture(App.Path & "\antonio.bmp")
    computer(3) = LoadPicture(App.Path & "\thomas.bmp")
    piccpu.picture = computer(Rand(1, 3))
    End Sub

    Private Sub Form_Load()
    opponent
    End Sub
    Walter Richardson
    Striver2000 Christian Productions
    Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    try this instead

    VB Code:
    1. Public Function Rand(ByVal Low As Long, ByVal high As Long) As Long
    2. Rand = Int((high - Low + 1) * Rnd) + Low
    3. End Function
    4.  
    5. Sub opponent()
    6. Dim computer(1 To 3) As String
    7. computer(1) = App.Path & "\carl.bmp"
    8. computer(2) = App.Path & "\antonio.bmp"
    9. computer(3) = App.Path & "\thomas.bmp"
    10. piccpu.picture = LoadPicture(computer(Rand(1, 3)))
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14. opponent
    15. End Sub
    Last edited by sebs; Apr 16th, 2002 at 10:35 AM.

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    Did you try making the varible a string?


    Also, can you use the [Highlight=VB] vb-code? It makes it easier to read the code.
    Involved in: Sentience

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