Solved

RichTextBox

Posted on 1999-01-12
1
262 Views
Last Modified: 2013-12-25
I need to be able to have a richtextbox that contains text that needs to be filled with results from another form.  It is like a questionaire and I want the results displayed in the RichTextBox within an rtf I have already loaded.  For example the template has the text Company Name:  I want the text from the form that is already filled out to appear next to the Company Name: <text from other form>  I know how to get it from the other form what I don't know is how to format it in the rtf.

Thanks in advance!
0
Comment
Question by:kmdisney
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
vbWhiz earned 20 total points
ID: 1489640
I have used the RichTextBox for creating form letters many times. The best solution I have come up with is like this:

Insert Certain Text into the letter in the richtextbox like '<<FirstName>>' then when placing the actual values into the letter use RichTextBox's built in search to replace '<<FirstName>>' with the actual value from the textbox.

To make life easier you could name each textbox from the form something intellegible like 'FirstName' or 'Address'. In the letter you would insert the names of the fields like this '<<FirstName>>' or '<<Address>>' to separate the fields from the rest of the text. Then you could use a routine like this to place the values into the RichTextBox - replacing the ugly '<<FirstName>>' type stuff.

SAMPLE CODE:

Public Sub InsertValues(TheSourceForm As Form)

Dim Ctrl As Control

For Each Ctrl In TheSourceForm.Controls

    If TypeOf Ctrl Is TextBox Then
        Do
            If Me.RichTextBox1.Find("<<" & Ctrl.Name & ">>") = -1 Then Exit Do
            Me.RichTextBox1.SelText = Ctrl.Text
        Loop
    End If
   
Next Ctrl

End Sub

To use this place a button on a form and on the click event insert some code like this:

RichTextForm.InsertValues Me


This will send the current form to the RichTextForm as a variable and allow the routine to cycle thru all the controls.

All you have to do now is create the other form. Name the fields and try it out!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question