|
-
Jun 28th, 2000, 07:57 AM
#1
Thread Starter
Hyperactive Member
Hi,
On my form I have 3 buttons - Biology, Physics, Chemistry. There is also another button, cmddiagram. If and when clicked this will give a form2 with a diagram of the topic in question : if biology is clicked, then it gives a diagram on biology, if physics is clicked...etc
Okay, the problem is that there is only one diagram button, and it can only show one particular diagram at a time - biology, physics or chemistry (depending on which of these has been clicked).
So I plan putting the code for each in a module. The buttons have code as follows:
Private sub cmdBiology_click()
Call Biology
end sub
Private sub cmdPhysics_click()
Call Physics
end sub
Private sub Chemistry()
Call Chemistry
end sub
My problem is, though, that I don't know how to fit the cmddiagram into all this. In my module, for instance, I have:
Public sub Biology()
'I don't know what code goes here, something
'like: if cmddiagram clicked = true Then
Form2!Show
Form2!Controls.Add "VB.line", "line1"
Form2!line1.X1 = 1560
Form2!line1.X2 = 1560
Form2!line1.Y1 = 1800
Form2!line1.Y2 = 4800
Form2!line1.Visible = True
End Sub
Any help or advice on this topic would be appreciated.
-
Jun 28th, 2000, 08:07 AM
#2
Lively Member
By button, do you mean a command button or a checkbox or a Radiobutton? I don't quite understand the question
If you mean there is a command button called cmdDiagram, and the other three are radiobuttons, then you'll need to do it like this:
Code:
Private Sub cmdDiagram_Click()
If cmdBiology.Value=1 then Biology
If cmdPhysics.Value=1 then Physics
If cmdChemistry.Value=1 then Chemistry
End Sub
Andrew Empson
vb6(ent) SP4
-
Jun 28th, 2000, 08:11 AM
#3
Replace your Biology, Physics and Chemistry buttons with radio buttons in a frame so that they will be mutually exclusive. Then when cmdDiagram is clicked it's an easy matter to determine which radio button was selected and based on that, to call the appropriate routine.
-
Jun 28th, 2000, 08:14 AM
#4
Lively Member
Andrew,
Thanks for the reply. I meant command buttons. There are four of them - cmdBiology, cmdPhysics, cmdChemistry and cmdDiagram.
CmdDiagram will show a different diagram, depending on which one of the 3 other has been clicked. I'm sure this is possible, isn't it?
-
Jun 28th, 2000, 08:26 AM
#5
Addicted Member
of course its possible, it sould be something like this:
[code]
dim strSubject as string
Private sub cmdBiology_click()
strSubject = "Biology"
end sub
Private sub cmdPhysics_click()
strSubject = "Physics"
end sub
Private sub Chemistry()
strSubject = "Chemistry"
end sub
Private Sub cmdDiagram_Click()
Eelect case strSubject
case "Biology"
'Show your Biology Form
case "Physics"
'Show your Physics Form
case "Chemistry"
'Show your Chemistry Form
End Select
End Sub
hope this works
-
Jun 28th, 2000, 08:36 AM
#6
Code:
'general declarations
Dim BioPhysChem(2) As Boolean
Private Sub cmdBiology_Click()
BioPhysChem(0) = True
BioPhysChem(1) = False
BioPhysChem(2) = False
End Sub
Private Sub cmdPhysics_Click()
BioPhysChem(1) = True
BioPhysChem(2) = False
BioPhysChem(0) = False
End Sub
Private Sub cmdChemistry_Click()
BioPhysChem(2) = True
BioPhysChem(0) = False
BioPhysChem(1) = False
End Sub
Private Sub cmdDiagram_Click()
Select Case True
Case BioPhysChem(0)
' biology code
Case BioPhysChem(1)
'physics code
Case BioPhysChem(2)
' chemistry code
End Select
End Sub
this is more work then necesary, you COULD use an option button,
it would be simpler, and there would be less code, but this works too.
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
|