CheckBox colors Textlabel automatically and reverse

Started by Beniii38, January 11, 2016, 08:17:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Beniii38

Hello everyone

I want to create a layout for our company, that shows many objects if they are included in the contract shown as green or red.
In this case I want a CheckBox that colors a label to red, if the CheckBox is False and to green, if the CheckBox is True and this automatically.

My Code:

Private Sub Label1_Click()
If CheckBox1.Value = True Then
Label1.BackColor = &HFF00&
End If
End Sub

If I add:

Private Sub Label1_Click()
If CheckBox1.Value = True Then
Label1.BackColor = &HFF00&
Else
If CheckBox1.Value = False Then
Label1.BackColor = &HFF&
End If
End Sub

there will be an error message:
"If-Block without End-If"

It doesn't work automatically, first when I click on the Textlabel.
Is my idea at all possible or even not?
Or do you have the Code to make it possible?

Thanks soo much  :)

Surrogate

try
Private Sub Label1_Click()
If CheckBox1.Value = True Then
Label1.BackColor = &HFF00&
Else
If CheckBox1.Value = False Then Label1.BackColor = &HFF&
End If
End Sub

or
Private Sub Label1_Click()
If CheckBox1.Value = True Then ' 1st level IF
Label1.BackColor = &HFF00&
Else ' 1st level Else
If CheckBox1.Value = False Then ' 2nd level IF
Label1.BackColor = &HFF&
End If ' 2nd level End
End If ' 1st level End
End Sub

Beniii38

Wow that works amazing  :) :) :)
Thank you soo much :)

Have a nice day :)

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 170 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1087KB.
Tokens: post-login.
Cache hits: 12: 0.00176s for 26,583 bytes (show)
Cache misses: 1: (show)
Queries used: 17.

[Show Queries]