|
-
Apr 16th, 2002, 10:27 AM
#1
Thread Starter
Fanatic Member
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!
-
Apr 16th, 2002, 10:30 AM
#2
Frenzied Member
try this instead
VB Code:
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 String
computer(1) = App.Path & "\carl.bmp"
computer(2) = App.Path & "\antonio.bmp"
computer(3) = App.Path & "\thomas.bmp"
piccpu.picture = LoadPicture(computer(Rand(1, 3)))
End Sub
Private Sub Form_Load()
opponent
End Sub
Last edited by sebs; Apr 16th, 2002 at 10:35 AM.
-
Apr 16th, 2002, 10:34 AM
#3
Fanatic Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|