Visio Guy

Visio Discussions => Programming & Code => Topic started by: Beniii38 on January 11, 2016, 08:17:55 AM

Title: CheckBox colors Textlabel automatically and reverse
Post by: Beniii38 on January 11, 2016, 08:17:55 AM
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  :)
Title: Re: CheckBox colors Textlabel automatically and reverse
Post by: Surrogate on January 11, 2016, 09:45:19 AM
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
Title: Re: CheckBox colors Textlabel automatically and reverse
Post by: Beniii38 on January 11, 2016, 11:07:46 AM
Wow that works amazing  :) :) :)
Thank you soo much :)

Have a nice day :)
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 51 (show)
Files included: 25 - 925KB. (show)
Memory used: 747KB.
Tokens: post-login.
Cache hits: 8: 0.00189s for 22,302 bytes (show)
Cache misses: 2: (show)
Queries used: 11.

[Show Queries]