Hi hope someone can help,

command1.click

if line1.bordercolor = vbBlack then
line1.bodercolor = vbRed
else
line1.bodercolor = vbBlack
End if
end sub

I need each time I hit the command button for a line (line1.bordercolor) to toggle between red and black.
I'm switching on a wire in a circuit and showing that the wire is on.

[ off ]-----Black----------------[ ]

[on]-------Red-----------------[ ]

sorry but I cant work it out, your help is very much appriciated. Many thanks in advance.

You misspelled bordercolor

line1.bodercolor = vbRed
line1.bodercolor = vbBlack

line1.bordercolor = vbRed
line1.bordercolor = vbBlack

Hi hope someone can help,

command1.click

if line1.bordercolor = vbBlack then
line1.bodercolor = vbRed
else
line1.bodercolor = vbBlack
End if
end sub

I need each time I hit the command button for a line (line1.bordercolor) to toggle between red and black.
I'm switching on a wire in a circuit and showing that the wire is on.

[ off ]-----Black----------------[ ]

[on]-------Red-----------------[ ]

sorry but I cant work it out, your help is very much appriciated. Many thanks in advance.

The code you'd need is as follows, but like SCBWV said, bordercolor has been misspelt in your example code.

Private Sub Command1_Click()
	If line1.bordercolor = vbBlack Then
		line1.bordercolor = vbRed
	Else
		line1.bordercolor = vbBlack
	End If
End Sub
This article has been dead for over six months. Start a new discussion instead.