Append a line to Richtexrbox by using underscore(_) using vb6

Why does this not work ?
Private Sub lblInsertLine_Click()
  Dim strLine As String
   strLine = String$(90, "_") 'rtf width is about 90 spaces
'Debug.Print strLine
   rtfTask.SelStart = Len(rtfTask.TextRTF)
   rtfTask.TextRTF = rtfTask.TextRTF & vbCrLf & strLine
   FactStart 'Sub to put cursor at the end of rtf
End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Change line 6 to

 rtfTask.Text = rtfTask.Text & vbCrLf & strLine
isnoend2001Author Commented:
Thanks, that inserts the line at the end of the rtf,but the images above are missing
Martin LissOlder than dirtCommented:
Would it be possible to post your project including an image and to give me instruction on when to click the label?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Martin LissOlder than dirtCommented:
Without having your project to work with, this works for me.

Private Sub lblInsertLine_Click()
Dim lngPos As Long

lngPos = InStrRev(rtfTask.TextRTF, "\par }")
rtfTask.TextRTF = Left$(rtfTask.TextRTF, lngPos - 1) & _
"\par __________________________________________________________________________________________" & _
"\par }"

End Sub

Open in new window

If you need to modify it for your circumstances, put a breakpoint before and after my new line 6 in your original code and at both points type ?rtfTask.TextRTF in the Immediate Window and see what the TextRTF looks like before and after the line is added. Then change this code as necessary.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Thanks that works
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
Martin LissOlder than dirtCommented:
BTW, just a thought, but I assume you have an automated way to add images to your RTB. If so and if you could create and image of a line then you could add that image instead of the underscores.
isnoend2001Author Commented:
Thanks, thought of that, but i just lasso images and paste.
made this for my personal use and was always holding down the underscore key to make lines to separate  items. so i decided to make the clickable label to automate the process. your code does just that
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.