|
Thread: hi
-
Nov 4th, 2002, 05:44 PM
#1
Thread Starter
New Member
hi
Does anyone have rolling two dice code for me looking at it?
-
Nov 4th, 2002, 06:20 PM
#2
Addicted Member
Umm, you're talking about 2 lines of code. Look at the Rnd function.
-
Nov 4th, 2002, 06:28 PM
#3
Stuck in the 80s
You're so helpful, Machaira. Maybe we should give you a reward.
Take a look at this, VBHelp2003:
VB Code:
'make sure you add a CommandButton first
Private Sub Command1_Click()
Randomize
MsgBox "You rolled a " & Int(Rnd * 6) + 1 & "!"
End Sub
-
Nov 4th, 2002, 06:32 PM
#4
Frenzied Member
Originally posted by The Hobo
You're so helpful, Machaira. Maybe we should give you a reward.
As far as I can tell, he posted all you need to know. Posting code is akin to cheating on a test. You learn nothing.
Z.
-
Nov 4th, 2002, 06:38 PM
#5
Thread Starter
New Member
thank hobo, so if I want sum of rolling two dice, I just add
sum = roll1 + roll2 ?
Zaei! tests are not easy kind of this questions.
-
Nov 4th, 2002, 06:59 PM
#6
Stuck in the 80s
Originally posted by Zaei
As far as I can tell, he posted all you need to know. Posting code is akin to cheating on a test. You learn nothing.
Z.
So there's no possible way to examine the code and learn from it?
He asked for code to look at. I gave it to him. Sue me.
-
Nov 4th, 2002, 08:05 PM
#7
Lively Member
Originally posted by The Hobo
Sue me.
How much do you think I can get.
-
Nov 4th, 2002, 08:17 PM
#8
Member
hey,
have u gotten a check yet for spedia.com... as in...does it actually work or has it worked for u??
Wombat
"I like to go to the schoolyard where i can watch the little kids jumping and screaming....but they dont know im using blanks"
"Before you set yourself on fire, remember to take off your shoes... nothing smells worse than burning rubber."
"They advertise that certain laundry detergents can take blood stains out of clothes, i say that if you have blood stains on your clothes, maybe your laundry is the least of your worries."
Sometimes when I'm driving around I see a sign that says, CAUTION: SMALL CHILDREN PLAYING. I slow down, and then it occurs to me: I'm not afraid of small children.
"My programs dont have bugs, they have random features" - MisianThrop
"The good thing about our ticket to the future is that it's always blank" - Trigun
-
Nov 4th, 2002, 09:23 PM
#9
Frenzied Member
Originally posted by The Hobo
So there's no possible way to examine the code and learn from it?
He asked for code to look at. I gave it to him. Sue me.
Asking questions instead of providing answers is a much more effective teaching tool. Provide new avenues to explore, instead of simply pointing out a single one.
Z.
-
Nov 4th, 2002, 09:50 PM
#10
Stuck in the 80s
Originally posted by Zaei
Asking questions instead of providing answers is a much more effective teaching tool. Provide new avenues to explore, instead of simply pointing out a single one.
Thanks for providing your opinion.
-
Nov 4th, 2002, 10:32 PM
#11
Lively Member
Originally posted by CrazedWombat
hey,
have u gotten a check yet for spedia.com... as in...does it actually work or has it worked for u??
Nope, No check, But that is just because I have never qualified for one. But aperantly (yes I have actually studied these guys out) They are one of the only companys that does pay, This is due to the fact that They have advanced Cheat detecting motives. But they are supposed to be Legitamite.
-
Nov 4th, 2002, 10:48 PM
#12
Frenzied Member
Originally posted by The Hobo
Thanks for providing your opinion.
You're welcome.
Z.
-
Nov 4th, 2002, 11:53 PM
#13
Addicted Member
Originally posted by The Hobo
He asked for code to look at. I gave it to him. Sue me.
So if he had asked for the code for a craps game would you have given it to him? Where do you draw the line? Will you continue to give him the code he needs since he's never going to learn how to research his problems to find the answers he needs? If he had taken the information I gave him, it would have taken him under 30 seconds to find the answer to his question.
I spend hours on various boards helping people and it's not hard to tell the difference between people that have tried to find the answer themself and are posting as a last resort and people that don't want to even attempt to find the answer, and just want the solution handed to them.
You're not doing the latter type person any favors by just giving the code to them.
-
Nov 5th, 2002, 12:07 AM
#14
Stuck in the 80s
Originally posted by Machaira
So if he had asked for the code for a craps game would you have given it to him? Where do you draw the line?
It was a dice snippet. Like you said, two lines. I'm not going to give full application code. It's a matter of extremes.
Originally posted by Machaira
Will you continue to give him the code he needs since he's never going to learn how to research his problems to find the answers he needs? If he had taken the information I gave him, it would have taken him under 30 seconds to find the answer to his question.
While we're being so exact (and not exaggerative), you have no way of knowing that it'd take him under 30 seconds. For all we know he can have a 14.4 modem and would take him 2 minutes just to load a simple webpage.
Originally posted by Machaira
I spend hours on various boards helping people and it's not hard to tell the difference between people that have tried to find the answer themself and are posting as a last resort and people that don't want to even attempt to find the answer, and just want the solution handed to them.
1) Get a life, and 2) realize that you can't predict everybody. Maybe this was his last resort. Maybe he doesn't speak much English and simply doesn't know how to effectively search.
Originally posted by Machaira
You're not doing the latter type person any favors by just giving the code to them.
Yes I am. I'm answering his question. That's not a favor? And don't tell me he needs to learn it on his own. He can learn it by looking at the code. It's not that complicated.
Not everyone learns the same way, either. Some people need visuals, some people need to read, some people need examples.
So go cry me a river, buttercup. I'll answer questions the way I see fit, regardless of whether or not you like it.
-
Nov 5th, 2002, 09:02 AM
#15
Member
hey
hobo is right, the only way i ever learned/learn is through examples, if i hadnt known that code i would be grateful, and if u spend hours on here helping people out, is ur previous reply the only help u give them? vague objectives...?? what if it was something much more complicated? would u have said look in a book? remember that u were a noob once too and however long ago that was, u didnt even know what random meant. so be kool and spend ur hours with more information than present, and Hobo, your way is best.
Wombat
"I like to go to the schoolyard where i can watch the little kids jumping and screaming....but they dont know im using blanks"
"Before you set yourself on fire, remember to take off your shoes... nothing smells worse than burning rubber."
"They advertise that certain laundry detergents can take blood stains out of clothes, i say that if you have blood stains on your clothes, maybe your laundry is the least of your worries."
Sometimes when I'm driving around I see a sign that says, CAUTION: SMALL CHILDREN PLAYING. I slow down, and then it occurs to me: I'm not afraid of small children.
"My programs dont have bugs, they have random features" - MisianThrop
"The good thing about our ticket to the future is that it's always blank" - Trigun
-
Nov 5th, 2002, 01:44 PM
#16
Thread Starter
New Member
*Estimate the probabilities of obtaining 2 through 12 when rolling two dice and summing the face values by simulation. The experiment should be performend N (input variable) times.
My output come out
2
3
4
5
6
7
8
9
10
11
12
Option Explicit
Dim x As Integer
Dim sum As Integer
Dim roll1 As Integer
Dim roll2 As Integer
Dim freq(2 To 12) As Integer
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdRoll_Click()
Call Randomize
roll1 = 1 + Int(Rnd() * 6)
roll2 = 1 + Int(Rnd() * 6)
sum = roll1 + roll2
freq(sum) = freq(sum) + 1
For x = LBound(freq) To UBound(freq)
lstList1.AddItem x & vbTab & freq(x) & vbTab & vbTab & Format$(freq(x) + freq(sum))
Next x
End Sub
-
Nov 5th, 2002, 01:48 PM
#17
Thread Starter
New Member
*Estimate the probabilities of obtaining 2 through 12 when rolling two dice and summing the face values by simulation. The experiment should be performend N (input variable) times.
My output come out:
2 0 1
3 0 1
4 0 1
5 0 1
6 0 1
7 1 2
8 0 1
9 0 1
10 0 1
11 0 1
12 0 1
Can someone help me about this output? thank
Option Explicit
Dim x As Integer
Dim sum As Integer
Dim roll1 As Integer
Dim roll2 As Integer
Dim freq(2 To 12) As Integer
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdRoll_Click()
Call Randomize
roll1 = 1 + Int(Rnd() * 6)
roll2 = 1 + Int(Rnd() * 6)
sum = roll1 + roll2
freq(sum) = freq(sum) + 1
For x = LBound(freq) To UBound(freq)
lstList1.AddItem x & vbTab & freq(x) & vbTab & vbTab & Format$(freq(x) + freq(sum))
Next x
End Sub
-
Nov 5th, 2002, 01:51 PM
#18
Frenzied Member
Make your listbox wider...
THe code works fine, though Im sure it would be annoying to have to repeatedly click the cmdRoll button....
Z.
-
Nov 5th, 2002, 02:50 PM
#19
Thread Starter
New Member
My listbox is fine.
But the output must be
after rolling two dice, for example 4 3
it suppose be 7 right? because 4 + 3 = 7 (sum)
-
Nov 5th, 2002, 03:31 PM
#20
Frenzied Member
sum is a global variable. It will immediatly add whatever the last roll was to the third column, which makes no sense.
Also, You are going to run into problems when rolling... 1 + int(rnd() * 6) returns in a range 1..7.
Z.
[edit]
See what I mean about posting code?
-
Nov 5th, 2002, 03:32 PM
#21
Frenzied Member
Err, actually it will add the number of "sum"s that have been rolled previously.
Z.
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
|