|
-
Jul 4th, 2000, 05:14 AM
#6
Thread Starter
Hyperactive Member
What I am trying to acheive and seem to have acheived:
Lots of buttons on my form. Each one does something different. One button, Command2, does a task depending on the button that was just clicked before it. Coomand2 does nothing until a button is clicked.
Example:
Program starts and user clicks command2. Nothing happens because there's no code in command2.
User clicks command1. Then Command2 does whatever command1 does, when command2 is clicked.
User clicks command3. Then Command2 does whatever command3 does, when command2 is clicked.
MartinLiss, I altered your code a bit and got it working:
'On my form, 3 command buttons and Picturebox
Public checkfunction
Private Sub Command1_Click()
'Randomnumbers is called in the module
Call Randomnumbers
'give checkfunction a value
checkfunction = 1
End Sub
Private Sub Command3_Click()
'Statistics is called
Call statistics
'give checkfunction a value
checkfunction = 2
End Sub
Sub Command2_Click()
If checkfunction = 1 Then
Call Randomnumbers
End If
If checkfunction = 2 Then
Call statistics
End If
End Sub
'In a module
'This is the code of 'Randomnumbers' in the module:
Public Sub Randomnumbers()
Form1.Picture1.Refresh
Form1.Picture1.AutoRedraw = False
Form1.Picture1.CurrentX = 10
Form1.Picture1.CurrentY = 10
Form1.Picture1.Print Int(Rnd * 20)
End Sub
Public Sub statistics()
Form1.Picture1.Refresh
Form1.Picture1.AutoRedraw = False
Form1.Picture1.CurrentX = 10
Form1.Picture1.CurrentY = 10
Form1.Picture1.Print "4 5 2 9"
End Sub
It works, but I'm curious:
How come it works when I put only 'Public Checkfunction' in General Declarations, without As Integer, or As Variable etc...?
How come it doesn't work when I put Checkfunction=0, instead of 1 or 2?
Thanks!
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
|