|
-
May 19th, 2000, 04:36 PM
#1
Thread Starter
Fanatic Member
hi,
i am trying to write a program that has six pictures of the six sides of a dice, and when i click on a button i want the program to randomally choose one of these pictures, and display it
can anyone help me
Merlin ?
-
May 19th, 2000, 04:55 PM
#2
Hyperactive Member
Try something like this:
dim intNumber as Integer
randomize
intNumber = int((6 * rnd) + 1)
select case intNumber
case 1
image1.picture = 'Put the picture
case 2
image2.picture = ' put the picture
etc....
Hope this helps
-
May 19th, 2000, 05:11 PM
#3
Thread Starter
Fanatic Member
another error
hi,
now i get the message
type miss match
it is on the line with the **
Private Sub Command1_Click()
Dim intNumber As Integer
Randomize
intNumber = Int((6 * Rnd) + 1)
Select Case intNumber
Case 1
**Image1.Picture = "C:\My Documents\vb\Total Domination\dice 1.jpg "
Case 2
Image2.Picture = "C:\My Documents\vb\Total Domination\dice 2.jpg"
MsgBox ("2")
Case 3
Image3.Picture = "C:\My Documents\vb\Total Domination\dice 3.jpg"
MsgBox ("3")
Case 4
Image4.Picture = "C:\My Documents\vb\Total Domination\dice 4.jpg"
MsgBox ("4")
Case 5
Image5.Picture = "C:\My Documents\vb\Total Domination\dice 5.jpg"
MsgBox ("5")
Case 6
Image6.Picture = "C:\My Documents\vb\Total Domination\dice 6.jpg"
MsgBox ("6")
End Sub
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
May 19th, 2000, 05:18 PM
#4
transcendental analytic
String is not a picture, that's why you get a type mismatch. Use image1.picture=Loadpicture(yourfilename) to get your picture
And also you don't need to have that select case. Put:
Image1.picture= Loadpicture ("C:\My Documents\vb\Total Domination\dice " & intnumber & "1.jpg")
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 19th, 2000, 05:31 PM
#5
Hyperactive Member
Hi,
You need to use the LoadPicture method:
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 1.jpg")
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 2.jpg")
etc...
-
May 19th, 2000, 06:15 PM
#6
Thread Starter
Fanatic Member
thanks but....
hi,
thanks that but now works
but when i try and make it for two dice they both come out with the same number
any way of them being different ?
code used so far...
Private Sub Command1_Click()
Dim intNumber As Integer
Randomize
intNumber = Int((6 * Rnd) + 1)
Select Case intNumber
Case 1
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 1.jpg")
Case 2
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 2.jpg")
Case 3
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 3.jpg")
Case 4
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 4.jpg")
Case 5
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 5.jpg")
Case 6
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 6.jpg")
End Select
Select Case intNumber
Case 1
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 1.jpg")
Case 2
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 2.jpg")
Case 3
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 3.jpg")
Case 4
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 4.jpg")
Case 5
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 5.jpg")
Case 6
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice 6.jpg")
End Select
End Sub
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
May 19th, 2000, 08:15 PM
#7
transcendental analytic
Code:
Private Sub Command1_Click()
Dim Num1%,Num2%
Randomize timer
Num1 = Int((6 * Rnd) + 1)
Num2 = Int((6 * Rnd) + 1)
Image1.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice " & Num1 & ".jpg")
Image2.Picture = LoadPicture("C:\My Documents\vb\Total Domination\dice " & Num2 & ".jpg")
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 19th, 2000, 09:19 PM
#8
Thread Starter
Fanatic Member
cheers
cheers kedaman
it works well now
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
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
|