Toggle Label's Border Style

J

JamesJ

I'm using the following to toggle initiate bold and/or underline in a
RichText control. Someone in the activex newsgroup was kind
enough to give me this code.

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyB And Shift = 2 Then

Me!axcRichText.SelBold = Not Me!axcRichText.SelBold

End If

If KeyCode = vbKeyU And Shift = 2 Then

Me!axcRichText.SelUnderline = Not Me!axcRichText.SelUnderline

End If

End Sub

What I would like to have is an indication on the form whether bold and/or
underline
is active by changing a labels border style to transpaerant if false and
solid if true.
I know I can set the label's border style to solid when the KeyCode is fired
but don't know how to toggle it back to transparent.

Any help will be appreciated.

Thanks,
James
 
D

Douglas J. Steele

Me!axcRichText.BorderStyle = 0 should be transparent,
Me!axcRichText.BorderStyle = 1 should be solid.
 
J

JamesJ

Yes. But, I'm not sure where in the code to insert
Me!axcRichText.BorderStyle = 0 and allow it to toggle
from 0 to 1. When I insert Me!axcRichText.BorderStyle = 1
below Me!axcRichText.SelBold = Not Me!axcRichText.SelBold
how do I switch back to transparent when the same keys are struck?

James
 
D

Douglas J. Steele

If KeyCode = vbKeyB And Shift = 2 Then
Me!axcRichText.SelBold = Not Me!axcRichText.SelBold
If Me!axcRichText.SelBold Then
Me!axcRichText.BorderStyle = 1
Else
Me!axcRichText.BorderStyle = 0
End If
End If
 
J

JamesJ

Duh. Nested Ifs. Works fine.

Thanks.
James

Douglas J. Steele said:
If KeyCode = vbKeyB And Shift = 2 Then
Me!axcRichText.SelBold = Not Me!axcRichText.SelBold
If Me!axcRichText.SelBold Then
Me!axcRichText.BorderStyle = 1
Else
Me!axcRichText.BorderStyle = 0
End If
End If
 

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