Link to home
Start Free TrialLog in
Avatar of Jhovyn Marcos
Jhovyn Marcos

asked on

how to know if my Checkbox is True in VB6.0?

Sir I have a Question.......I have 2 Forms namely "form1" and "form2"....how do I call my checkbox in form2 if it is True? Can you give me some simple code?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

If Form2.MyCheckBox.Value = True then 'Or vbChecked in place of True
you should always use vbChecked and vbUnChecked intrinsic constants when determining checkbox value.  True is not equal to vbChecked
A Vb6 checkbox can actually have 3 values:
vbChecked or Checked, both of which = 1
vbUnChecked or UnChecked, both of which = 0
vbGrayed which is 2
Avatar of Jhovyn Marcos
Jhovyn Marcos

ASKER

In my "form1" I have this code

    Private Sub chkRegisteredLocation_Click()

    If checkbox1.value = 1 Then
    datacombo1.Enabled = True
    Else
    checkbox1.Enabled = False
    datacombo1.Text = ""

    End If
    End Sub

Now in my "form2" how do I know if my checkbox1 is True or Checked?
Hi,
Try like below- <<txt is a text box from form2.>>

txt.text  =  form1.checkbox1.Value

Hope it helps!
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

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
If it is set to three state it can have more than two values.
Thank you :)
You're welcome and I'm glad I was able to help.

If you expand the “Full Biography” section of my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2015