i need to bold some text as i add them to the richtextbox control, currently here is my code
EDIT
With txtDetails
If Not IsNullOrEmpty(title) Then
Dim intStart As Integer
intStart = Len(.Text)
.Text = .Text & title '& vbCrLf
.SelStart = intStart
.SelLength = Len(title)
.SelBold = True
.SelLength = 0
.SelBold = False
.Text = .Text & vbNewLine
End If
If Not IsNullOrEmpty(value) Then
.Text = .Text & value & vbNewLine
End If
.Text = .Text & vbNewLine
End With
can anyone help me with the fix
I have made changes to the code, but still get all the subsequent test i add to be bold, insted of the one am interested in
It looks like you want to append a bolded
titleif not “missing” and a non-boldedvalueif it is not “missing.”Here I’m using TextBox controls as the data source but it should give you the general idea. It is often cheaper to use two operations than using String concatenation to add a newline.
Fetching the current .Text and measuring it with Len() is also costly if the contents are large, so just set .SelStart to the maximum value to move to the end.