Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bold text within Normal text 1

Status
Not open for further replies.

Phudsen

Technical User
Mar 7, 2003
136
A2
Hi,

I have a form which has a combo box. The combo box lists cheque numbers. When the user selects a cheque number, a message will be displayed in a text box down saying that "You have selected cheque number 12345. Please click...etc". The text is written by me, but the cheque number is taken from the combo box cboChequeNumber. How can I make only the cheque number in bold.

Here is the code that I put in the after update event of the combo box. It is working fine.

I tried FontBold=True and FontWeight, but didn't work.

Me.txtDesc = "You selected cheque number " & Me.cboChequeNumber & " .Please click the right button that related to what you want to do with the cheque"


txtDesc is the textbox that shows the message.

Thanks
Paulin
 
Take a look at the RichTextBox control.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
In the list of additional controls that you can add to a form.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I selected More Controles but did not find it in the list.



 
Hi,

I don't know what the RichTextControl does. But I don't want to type myself and highlite then select Bold. I want the text to be displayed in the textbox with the Cheque number in Bold.

Thanks
 
Hi,

I found it.

This is not what I want. I want the whole message to appear in Normal mode and only the cheque number to appear in Bold. I can make the whole text appear in bold without thanks RichTextControl.

 
Gee, well I don't know what to say. Perhaps you could try the following: Place a RichTextBox control on the form where you would like it to be. Then I'm calling this procedure from a command button with literals, but you may need to call it at some other point with the appropriate values.
Code:
Private Sub cmdImport_Click()
   
   SetRichTextBox "You have selected cheque number", "12345", ". Please click...etc."

End Sub

Private Sub SetRichTextBox(rStr_FrstPart As String, rStr_CheckNo As String, rStr_LastPart As String)

   Dim lInt_StartBold   As Integer
   Dim lInt_BoldLen     As Integer
   
   lInt_StartBold = Len(Trim(rStr_FrstPart)) + 1
   lInt_BoldLen = Len(Trim(rStr_CheckNo))
   
   rtbRichTextBox = Trim(rStr_FrstPart) & " " & Trim(rStr_CheckNo) & " " & Trim(rStr_LastPart)
   rtbRichTextBox.SelStart = lInt_StartBold
   rtbRichTextBox.SelLength = lInt_BoldLen
   rtbRichTextBox.SelBold = True
   
End Sub
Perhaps I misunderstood what you're asking, but this seems pretty close to me.



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hi CajunCenturion,

Thank you for your reply, I got the code I need. Here it is. I think it is similar to yours.

Code:
Private Sub cboChequeNumber_AfterUpdate()
  
    Dim myRich As RichTextBox
    Dim intPosNum As Integer           ' Position of the number in the string
    Dim s As String
    
    Set myRich = Me.RTB.Object
        
    myRich = ""
    s = "You selected cheque number " & Me.cboChequeNumber & " . Please click the right button that related to what you want to do with the cheque"
    
   intPosNum = InStr(s, Me.cboChequeNumber)
    
   With myRich
      .Locked = False
      .Text = s
      .SelStart = intPosNum - 1
      .SelLength = Len(Me.cboChequeNumber)
      .SelBold = True
      .SelLength = 0
      .Locked = True
    End With

   Set myRich = Nothing
End Sub

It is similar to your code. This code is working perfectly and it displays the value taken from the combobox in bold. I'll try your code and get back to you.

Thank you
Paulin
 
The code is essentially the same. It's using the capabilities of the RichTextBox, and setting the bold on a Selected section of the text.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You're quite welcome. Perhaps you'll be able to return the favor by providing some help to another of your fellow IT professional seeking answers here at Tek-Tips, just as other IT professionals have spend their time trying to help you.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I would award an addititonal star for the kind words in addition to the patience with this thread (or at least it's originator). Unfortunatly the rules of the club don not permit it.

I think it is THE example of diplomacy and wish I could follow it. Alas my patientce runs out after three (or is it down to one or two?) examples of not even trying to follow the suggestion.




MichaelRed
mlred@verizon.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top