|
-
Sep 16th, 2000, 11:49 AM
#1
Thread Starter
Lively Member
Ok, I am kinda creating this "math" program to solve a game called krypto but I have a problem I need a code that can generate random : + , -, *,/, so that i can put them between variebles : A * B + C * D - E = G and have it generate the functions at random and place them between the variebles. Some help? Thanks
PS: I don't care if its an OCX, win API, or just plain old VB code as long as it does what I want it to!
Private Sub DeepCrap
on error blame microsoft
if microsoft = screwed then
blame aol
end if
end deep crap
Ahh VB6 Enterprise Edition
-
Sep 16th, 2000, 11:55 AM
#2
Try this:
Code:
Private Sub Command1_Click()
Randomize
RetVal = Int((4 * Rnd) + 1)
If RetVal = 1 Then RetSign = "+"
If RetVal = 2 Then RetSign = "-"
If RetVal = 3 Then RetSign = "*"
If RetVal = 4 Then RetSign = "/"
MsgBox RetSign
End Sub
-
Sep 16th, 2000, 12:03 PM
#3
Thread Starter
Lively Member
Hmmm i got the code but im still a little confused on how i can use it..can u please break it down a bit ... thanks a lot for the help
Private Sub DeepCrap
on error blame microsoft
if microsoft = screwed then
blame aol
end if
end deep crap
Ahh VB6 Enterprise Edition
-
Sep 16th, 2000, 12:09 PM
#4
Thread Starter
Lively Member
I mean i get how to generate a random function but how do i use it between 2 numbers like say the generated function is plus so how do i get it to do 1 + 2 and then check if that equals 3 thanks
Private Sub DeepCrap
on error blame microsoft
if microsoft = screwed then
blame aol
end if
end deep crap
Ahh VB6 Enterprise Edition
-
Sep 16th, 2000, 12:25 PM
#5
This is the only thing I could think of.
Code:
Private Sub Command1_Click()
Randomize
RetVal = Int((4 * Rnd) + 1)
If RetVal = 1 Then RetSign = "+"
If RetVal = 2 Then RetSign = "-"
If RetVal = 3 Then RetSign = "*"
If RetVal = 4 Then RetSign = "/"
If RetSign = "+" Then
RetNum = 5 + 5
ElseIf RetSign = "-" Then
RetNum = 5 - 5
ElseIf RetSign = "*" Then
RetNum = 5 * 5
ElseIf RetSign = "/" Then
RetNum = 5 / 5
End If
MsgBox RetNum
End Sub
-
Sep 16th, 2000, 06:43 PM
#6
It'll be much shorter if you use the Choose() function.
Add this to a Form with 2 TextBoxes and a CommandButton.
Code:
Randomize
Num = Choose(Int(Rnd * 4) + 1, Val(Text1) + Val(Text2), Text1 - Text2, Text1 / Text2, Text1 * Text2)
Print Num
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
|