• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

Check Box - For smart ppl

I have a problem. I am new to VB and was hoping if any of you could help me out.

I've created a several check boxes but once my click on the box it carries out my procedure. I would like to reverse his procedure to how it was before i clicked on it.

How can i do this ???

Below is a sample of a coding. Ignore the actual structure.

Within the checkbox click command>>>

Image1.visibility = true
Image2.visibilty = false


When clicked>>>Image1 shows and image 2 disappears.

I would like to reverse the process when i click again.

I would appreciate any help !!!

thank you
0
m0ley
Asked:
m0ley
  • 3
1 Solution
 
riduceCommented:
Here is you're answer

Private Sub Check1_Click()
If check1.value = 0 then image1.visible = false: image2.visible = true
if check1.value = 1 then image1.visible = true : image2.visible = false
End Sub
0
 
Erick37Commented:
Private Sub Form_Load()
    Image1.Visible = (Check1.Value = vbChecked)
    Image2.Visible = Not (Check1.Value = vbChecked)
End Sub

Private Sub Check1_Click()
    Image1.Visible = (Check1.Value = vbChecked)
    Image2.Visible = Not (Check1.Value = vbChecked)
End Sub
0
 
Erick37Commented:
A little improvement:

Private Sub Form_Load()
    Image1.Visible = (Check1.Value = vbChecked)
    Image2.Visible = Not Image1.Visible
End Sub

Private Sub Check1_Click()
    Image1.Visible = (Check1.Value = vbChecked)
    Image2.Visible = Not Image1.Visible
End Sub
0
 
Erick37Commented:
Even better:

Private Sub Form_Load()
    Check1_Click
End Sub

Private Sub Check1_Click()
    Image1.Visible = (Check1.Value = vbChecked)
    Image2.Visible = Not Image1.Visible
End Sub
0
 
m0leyAuthor Commented:
Cheers mate

It worked like a charm !!! :-)

Much appreciated and thank you once again
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now