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

Thank you for your help, I feel so stupid.:$

You can also use a counter to accomplish this task.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.