Link to home
Start Free TrialLog in
Avatar of NewsInternationalLtd
NewsInternationalLtd

asked on

VB6 Data table

I have created a vb6 app which consists of a form with 4 application titles and 2 checkboxes next to each title. What I need is a way to trigger certain events based on what checkboxes are ticked, eg

chk1 ticked, chk2 clear > set action1
chk1 ticked, chk2 ticked > set action2
chk1 clear, chk2 clear > set action3

What I am looking for is an elegant solution that avoids a whole bunch of If...Then statements. Part of the reason I need this is because I would like a msgbox to pop up to explain to the user that they have requested X action with Application1, Y action with application2 and Z action with application3 before commencing and and acting on the request.
Sounds fairly straightforward but I have been struggling to think of a way to do this that I'm happy with!

Your thoughts and suggestions are appreciated as always!

Avatar of Moeter
Moeter

Try this, I have choosen On Click, but you can use it whenever you want

two check boxes

Private Sub Check1_Click()
    If Check1.Value = 1 And Check2.Value = 0 Then
        MsgBox "First checked, second not"
    ElseIf Check1.Value = 1 And Check2.Value = 1 Then
        MsgBox "Both checked"
    ElseIf Check1.Value = 0 And Check2.Value = 0 Then
        MsgBox "Both Not checked"
    End If
End Sub
select case Check.1 + 2* Check.2
  case 0
    action3
  case 1
    action1
  case 2
    MsgBox "Not possible to check 2 and not 1"
  case 3
    action 2
end select

Of course, this is expandable to more check boxes (+ 4*Check.3 + 8*Check.4)

Avatar of NewsInternationalLtd

ASKER

Thanks.
The first solution is the way I have it at present.
I am intrigued by the second though.

Supposing the checkboxes are called AppOffice and AppFP. What is the syntax used for this? I'm trying to figure out exactly how it works.
ASKER CERTIFIED SOLUTION
Avatar of mikeydm
mikeydm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent, this is what I was looking for. However I would point out that the Case statements create a values of 1, 2, or 3 rather than their negetives. Still, the same principle so thanks.