image1.bordercolor not showing

D

Dave D-C

Hello,
I have an Image on a Userform that I want to flag/unflag
by changing the border color red/black. (Word97/WIN98)

Private Sub Image1_Click()
If Image1.BorderColor = RGB(0, 0, 0) Then
Image1.BorderColor = RGB(255, 0, 0)
TextBox1.Value = "red"
Else
Image1.BorderColor = RGB(0, 0, 0)
TextBox1.Value = "blk"
End If
DoEvents ' doesn't fix it
End Sub

The text "red"/"blk" works, but the color doesn't change.
"DoEvents" was a feeble try.
TIA, Dave
 
J

Jon Peltier

What's Image1.BorderStyle? If it's 0 (fmBorderStyleNone), it doesn't matter
what color you set, there's no border.

- Jon
 
P

Peter T

I can't see the OP in my newsreader, only quoted in Jon's reply.

Anyway, assuming the border is not 0 as Jon suggest, may well need to do a
Me.Repaint after changing the border colour. Personally I avoid both Repaint
and DoEvents unless absolutely necessary.

A better overall solution IMO is to use a label as the border which also
gives the option to resize the 'effective' border.

Add a Label to the form named Label1

Sub PicLabel(bFlag As Boolean)
Dim bdr As Single
Dim clr As Long

Me.Label1.ZOrder 1

If bFlag Then
bdr = 3
clr = RGB(255, 0, 0)
Else
bdr = 0.75
clr = 0
End If
With Me.Image1
Me.Label1.Move .Left - bdr, .Top - bdr, _
.Width + bdr * 2, .Height + bdr * 2
End With
Me.Label1.BackColor = clr

End Sub

Call PicLabel before showing the form, say in the Initialize event, with
bFlag True or False as required.

In Image1_Click() -
PicLabel (Me.Label1.BackColor = 0)

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top