Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Adding Text To Rich Textbox Without Changing Format Of Existing Text?


Hello all. This is my first time working with RTB's, and I'm having a little trouble getting started. I'm sure it's some little problem of syntax/semantics, but I can't figure it out. A little help would be greatly appreciated!

I have a RTB to which I am trying to add texts of different formats. When I add each string, the entire box text takes the most current format. This makes perfect sense to me, as I am essentially rewriting the ENTIRE textbox (I am using the ".Text = .Text & "NEWTEXT" format that I am accustomed to using for textboxes.

What am I doing wrong? Thanks!


VB Code:
'1.  Create a new form.'2.  Add a button named butGo.'3.  Add a RTB named rtbText.'4.  Cut & Paste the procedure below. Private Sub butGo_Click()Static Counter As IntegerCounter = Counter + 1With rtbText    Select Case Counter        Case 1: .Font.Size = 16                .Font.Bold = True                .Text = .Text & "This is a test..."        Case 2: .Font.Size = 12                .Font.Bold = False                .Text = .Text & "This is only a test!"        Case 3: .Font.Size = 6                .Font.Italic = True                .Text = .Text & "  Can you see me?"    End SelectEnd WithEnd Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Problem Adding Text To Existing Text In Field...
Hi,

I need some help, as always, I currently have a table called 'notificationMessageTbl' and I have a TEXT field called 'userReadID' what I want to do is add text to the end of current text within the field using SQL

If I use the following code it just replaces the exsisting text with '12,' and does not append.

Code:UPDATE notificationMessageTbl SET userReadID = '12,'

Thanks in advance

Simon

Changing Color Text Of Rich Text Box
how would i change the color of text ina RICXH TEXT BOX sand format it

Changing Text Color In A Rich Text Box
two fairly easy ones (hopefully!):

I want to change the text color in a rich text box any idea?
And:
For some reason the tab button makes the cursor disapear out of my rich text box, know how to fix this?

Anybody have any ideas?

Rich Text Format To Text Converter
I need a converter for my vb project to convert rich text format to text file.
are there any dll's out there?

thanks

kati

Rich Text Format To Text Converter
I need a rich text format to text converter to use in my Vb project.
Where can I find one?

Thanks

Kati

Text Encryption In Rich Text Format
How can i get ascii text encryption to work with a rich text box. An example i found such as this(below) will not work with a richtext box. Anyone have any ideas or examples to show me?..Working out of a rich text box and a password:
'Encrypt text
Private Function EncryptText(strText As String, ByVal strPwd As String)
Dim pwdpos As Integer, c As Integer
Dim strBuff As String

#If Not CASE_SENSITIVE_PASSWORD Then

'Convert password to upper case
'if not case-sensitive
strPwd = UCase$(strPwd)

#End If

'Encrypt string
If Len(strPwd) Then
For pwdpos = 1 To Len(strText)
c = Asc(Mid$(strText, pwdpos, 1))
c = c + Asc(Mid$(strPwd, (pwdpos Mod Len(strPwd)) + 1, 1))
strBuff = strBuff & Chr$(c And &HFF)
Next pwdpos
Else
strBuff = strText
End If
EncryptText = strBuff
End Function


~~~Thanx

Rich Text Box Format To Text File
I want to be able to save the contents of a Rich Text box to a text file so that the formating looks the same as the way it displayed on the screen. The rich text box does wrap the words correclty but when you save the text box conents, it's just one long string. Any ideas?

Adding Text To A Rich Text Box Dynamically !
Hi,
I'm writing an application that uses a Rich Text Box to display messages (e.g. errors or warnings) for processes that are running within the application.

I have a function that wites (appends) to this control and puts the cursor at the end so when the RTF control fills up it stays in view at the bottom, otherwise when a process has finished you have to scroll to the bottom of the window ! e.g.

Private Sub WriteToRTFControl(sText As String)
   rtfMain(0).Text = rtfMain(0).Text & sText
   SendKeys "^{END}"
End Sub

Is there an easier way to append more text to an RTF control ?

Can the cursor stay at the end of the window ?

How can I add colour or make the print bold for an error message ? I have used the .SelBold feature except it changes all of the contents rather than the text I've just added !

Thanks very much.
Mike

Text Format In Rich Text Box
i've got richtext box and i've set the font and size, ok, but when you copy and paste from another app into it, the font and size from the copied text is used. anyone know of a way to use the font and size i am using?. The only way i can think of is to select all the text in the rich text box and reset the font immediately after new text is added.

(please excuse the crap typing, got one arm in a sling after a nasty squash accident)

cheers

john

Need Some Help With A Rich Text, Adding Text On The Fly
I developed a very simplistic chat program that uses a database to save messages to when in the chat the program grabs the messages and posts them to an RTF adding on to whats there. This works ok but when trying to read a message further up on the scroll bar it will be disrupted the next time a message is posted. Is there any way to add the text without disrupting the current location of the scroll bar?

Rich Text Format
Hi There,

I have search all over the internet to find code to format a phrase but I haven't had much luck. Most of the code is for formatting keywords.

I finally got this code:

Code:
Public Sub RTBFormat(RTB As RichTextBox, sWord As String, sBold As Boolean, sItalic As Boolean, sColor As ColorConstants, intIndent As Double)
Dim i As Long
Dim p1 As Long, p2 As Long
Dim Text As String
Dim sTmp As String
Text = RTB.Text
p1 = InStr(1, Text, sWord)
Do While p1 > 0
RTB.SelStart = p1 - 1
RTB.SelLength = Len(sWord)
RTB.SelBold = sBold
RTB.SelColor = sColor
RTB.SelItalic = sItalic
RTB.SelIndent = intIndent
p1 = InStr(p1 + 1, Text, sWord)
Loop
End Sub

The only problem with this code is that everything is in the same formatting!!

For example if I have the sentence "Hello World" and I tell it to have hello red and world blue the whole text is in blue.

I am trying to use this code in a chat program I am making. Could some help improve it so it only modifies the phrase I want.

Thanks in adance,
James

Rich-Text-Format
Problem-Description:
I wrote a Macro which saves E-mails on HardDisk. I have two selectable Formats : *.msg & *.rtf . so i got the problem , that the Part with the rtf-Format doesn´t work proberly. Based on the fact, that i suppose that the (vba-outlook) - saveAs - Method- Call is correct it must depends on the content or (and) the file-appendix.

Does anybody knows more about it ?? ! !

THX NEXUS





Edited by - NeXuS_ONE on 11/4/2003 1:36:12 AM

How Can I Format Rich Text Box?
Please someone tell me how can i format rich text boxes such as changing color to some chareacters, making bold and more.

Rich Text Format
I looking a sample about how to paste a BMP from
clipboard, I tried this

rtfVista.OLEObjects.Add , , , Clipboard.GetData()

rtfVista.Refresh

I tried to get the RichText.vbp, which is located in
the VBSamplesCompTool directory of the Visual Basic
CD-ROM, but I couldnt find it, anybody will help me?

Thanks by your help
Alfredo

Rich Text Format
I am facing a problem where the .rtf file in rich text box are not in A4 size and this make my alignment are not in the right manner. Is the rich text box don't have a function where we can set the paper size as A4 or it only have a maximum size? Another problem is how can I load the table or line in winword and display in rich text box? Hope to get a sample program for the problem! Thanks...

Adding Text To Textbox Without Deleting Previous Text
Hello All

I'm new here. Been programming in VB 6.0 for a while but i'm a beginner.

I'm writing a sort of calculator that puts the results in a textbox. But when i get a new result i just want to add it to the textbox, but it erases the previous answer.
I can use a listbox (addItem) but I have to be able to copy the selection in the result field and i can't do that in a listbox.

In short.

Everytime i get a new result it has to edit the textfield, not clear it and start all over again.

TextBox1.Text = "result...."
That's the code i'm using to put in the result.

Anyone know a solution to this ?
Thanx in advance.

Changing Strings Into Rich Text Box
Howdy All,

I'm having some difficulties with converting strings into a rich text box.

I have a data acquisition device that receives numbers and places them into a string. The string looks like this:

-1.3733 -4.577 -1.983 -1.373 -1.3733 ...

The data comes from a variable number of channels off the data acquisition device. The first number would be channel 1, the second 2, and so on. The values are separated by two spaces. The device scans channels 1 to 5 and then returns to 1 and continues.

-1.3733 -4.577 -1.983 -1.373 -1.3733___-1.3733 -4.577 -1.983 -1.373 -1.3733...

If the device continues to collect data, scanning channel 1 again, the next 'row' of values is separated by three spaces, which I have underlined above.

As said previously, this data is collected in a string. I need to take this data and turn it into a space delimited text file, so the above data would look like:

-1.3733 -4.577 -1.983 -1.373 -1.3733
-1.3733 -4.577 -1.983 -1.373 -1.3733...

Right now I have a for loop from character 1 to the last character of the string. The loop reads each character and when it encounters three spaces adds a line return and a carriage return (Chr(13) & Chr(10)). The values are then transfered into a rich text box. The problem is that this is intensely time consuming for any file with more than 400 values.

Does anyone have any idea?????? Is there a quicker way to "cut up" the string, without scanning every single letter?

Thanks!

Rich Text Box Changing Color
Hi people! I have problems with RichTextBox Control.
My app runs a process and i have a richtextbox control to show information about the process being executed.
I have a

I have this sub "Informar" to write text to the richtextbox control and its parameters are :
Text to print to richtextbox, Forecolor for that specific text i have as a parameter, Fontname, FontSize and FontBold. (I pasted code below)

The problem it doesnt change forecolor nor fontsize ....
why? what am i doing wrong?


Code:
Private Sub Informar(ByVal sText As String, _
Optional ByVal cForeColor As OLE_COLOR = vbBlack, _
Optional ByVal sFontName As String = "Tahoma", _
Optional ByVal iFontSize As Integer = 8, _
Optional ByVal bFontBold As Boolean = False)

Dim iStart As Integer, iLen As Integer

With RichTextBox1
.Text = .Text & sText

iLen = Len(sText)
iStart = Len(.Text) - iLen

If iStart > 0 Then
.SelStart = iStart + 1
Else
.SelStart = 0
End If

.SelLength = (iLen + 1)

.SelFontName = sFontName
.SelFontSize = iFontSize
.SelColor = cForeColor
.SelBold = bFontBold
End With
End Sub

Private Sub Command1_Click()
RichTextBox1.Text = vbNullString
Informar "Información...", vbBlack
Informar vbCrLf & " D ", vbGreen, "Wingdings", 30, True
Informar " No se han encontrado tarjetas a procesar!", vbGreen, True
End Sub

Sorry my english and thanks in advanced!

Mail From Rich Text Format
Hi!

I would like to send a formatted email from a Rich Text Box from my own application.
I don’t want to send the RTF-text as an attach file, but as a formatted text witch appear formatted directly in the arriving mail.
How do I tell my application that I should send the mail as RTF format?
I use the Winsock control.
Is this possible?

Best regards
Magnus Pernsved

Rich Text Box Format Problem
I'm having some trouble with the RichTextBox. On the computer I developed the application on, it works fine, but all others that I've installed the app, it doesn't work properly. Somehow, when I'm hiding the form with the richtextbox, it looses it's bold, italic and superscript formatting (if any exists) and this is triggering the change event. The result is the user is asked if they want to save changes before they continue, even though no changes have been done. I've made sure that both machines are using the same version of RICHTX32.OCX. Has anyone seen this before? Is this a flaw in the control?

Thanks,
Scott

Changing Font Properties In Rich Text Box
I am making an application in which the computer will dialog with the user about any problem and the user can answer in "yes" or "no".
I have used rich text box for displaying the conversation. Now i want that whatever questions asked by computer should appear as bold and italic and the answer by user (yes or no) apear in noramal text with a different colour. (like chating software msn or yahoo have different colours for both persons)
How can i change the font proerties at every line. When i used the setfont proerty it change the whole rich text box properties.

Changing The Color Of The Font In A Rich Text Box
Is it possible to change the font color of a richtextbox?

thanks,
Doc

Changing Font Color In Rich Text Box
Hi, can u tell me how to change the font color in rich text box control..

I want few
line color to in red
and few in blue
and few in black.

how to get this.

thanks in adv.
venu

Funky Format Of RTF Rich Text Boxes
I have a VB5 app using rich text boxes to display data from RTF files. The files were created in Wordpad. At home the data displays correctly in the boxes both during development and when run. In work, this morning, I discover a right margin (?) in the box (so it appears) is causing the text to word wrap and mess up the format. Yet RightMargin is set to zero. Any clues?

AS WRITTEN (and displayed at home)
Plastics
Thermoforming is a process by
which a flat sheet of plastic is...

AS DISPLAYED
Plastics
Thermoforming is
a process by
which a flat
sheet of plastic
is...

Saving A File In Rich Text Format?
Hi,

I'm currently making a program which is much like Word, and I have decided to save all of the documents as a RTF file. I have worked out the common dialogue bit for saving, but when I paste a picture into the Rich Text Box, and save it, the picture isn't there! and the font that I have selected isn't there! It's always Courier New!!

Any help would be greatly appreciated,



Chris

Parsing Rich Text Format Files
I was wondering if anybody has ever tried to do this?

I'm trying to decide which way works the best. Either taking each rtf file and saving it in text format, then parse out the data...

-or-

Add a Microsoft Word reference to a vb project, open the file, read and parse out the data...

Any suggestions would be greatly appreciated!!!

Sending A Mail With Rich Text Format
Hi Guys,

I am trying to send mail from the code below. what parameters do i need to change to such that mail can be decrypted in the correct format. The attached file is the description of the mail i get.


************************************************************************
Public Function SendMail(strTo As String, strCC As String, strBody As Variant, strSubject As String)
Dim oItem As Outlook.MailItem
Set oOutlook = New Outlook.Application
Set oItem = oOutlook.CreateItem(olMailItem)
With oItem
    .To = strTo
    .CC = strCC
    .BodyFormat = olFormatRichText
    .Body = strBody
    .Subject = strSubject
    .send
End With
End Function
************************************************************************
Can anyone help me on this..

thanks

Adding Image To Rich Text Box
I am trying to add an image to my rich text box.


Code:
rtbResults.OLEObjects.Add = strCreateDrawingTypeImagePath

Here is the Run Time error I recieve:
32008 Required source document or class name is missing.

Can anyone help me out with what is causing the error, or how to solve this? Any help would be greatly appreciated.

Adding Tab Inside Rich Text Box
Can anyone tell me how to add a tab function in a rich text box?
I have a word like program and i need to add the ability to add tab functionality within a rich text box. Currently, if you hit tab, the program tabs to the next text box. I want it to stay within the current box and move over some amount of spaces to replicate a tab.

ugman

Adding Bullet To Rich Text Box
Does anyone know how I can add a bullet to a Rich Text Box?
I need to enter info into a Rich Text Box with bulleted items.

ugman

Adding Line To Rich Text Box
I would like to have line added after a line without loosing the line we added previously. For example

I add a line to the rich text box "The calculation is in progress...." and then I will run a program to get a result from the program. I would then trying to inform the user in the same RTB "Calculation completed, result is bra bra bra" without loosing the first line.
Thanks.

Adding A New Line To A Rich Text Box
Can anybody please tell me how do i add a new line at the top of a rich text box and move the text down.
Just the same as if you press enter the text after the cursor would all move down one line. I need a command button to do this how do i do it
Thanks

Rich Text Box (Adding Graphics)
Well when i try to add a new graphic to the Rich Text Box the image is added to de box but it also opens te image on a default image application.
What can I do to never let the other application to be open?

Covert Rich Text Content To HTML Format
I have some formatted content in the Rich text Box. Is there any way to convert the contents to HTML so that i can display it in Outlook email message window.

My requirement is to format some text contents to be included before sending an automated email through MS Outlook

Help Please....

Help!!! To Export Acess Report To Rich Text Format Through Vb6.0
Dear friends

I am creating a project in which i want to export access report to rich text format through vb. Is there any way to day that.

Plz!!! help its urgent

Thanks in advance

shivpreet2k1

Rich Text Box Usage For Read-only File (RTF Format)
Hi, I'm working on opening a Rich Text Box to display a file that will be read-only for a .RTF file. I'm trying to get it so that the cursor doesn't appear in the box, and have a scroll bar appearing on the right hand side. I think I can do it using the enabled function set to false, and using a vertical scroll bar, but I'm not quite sure how to. I know how to use scroll bars, but I just don't see how I can code it to scroll up and down the text in a Rich Text Box. Can anyone help?

Mapi And Rich Format Text In Message Body ???
Hello

I am trying to send email using MAPI controls and i want the text of Body to be in Rich Format.

I tried this with RichTextBox but no result.

does anyone have any idea ???

thanks

Sending A Mail With Rich Text Format -Correct
Hi Guys,

I am trying to send mail from the code below. what parameters do i need to change to such that mail can be decrypted in the correct format. The attached file is the description of the mail i get.


************************************************************************
Public Function SendMail(strTo As String, strCC As String, strBody As Variant, strSubject As String)
Dim oItem As Outlook.MailItem
Set oOutlook = New Outlook.Application
Set oItem = oOutlook.CreateItem(olMailItem)
With oItem
    .To = strTo
    .CC = strCC
    .BodyFormat = olFormatRichText
    .Body = strBody
    .Subject = strSubject
    .send
End With
End Function
************************************************************************
Can anyone help me on this..

thanks

Dynamically Adding New Lines In A Rich Text Box
Hi folks,

I'm developing an application that needs a text editor that limits the number of characters to a max of 150 and has the ability to bold the line (so I have to use a rich text box). The problem I'm having is when I get to the line limit, I can't get a hard break to be inserted into the text so the cursor is moved to the beginning of the next line automatically. I've tried:

txt = rchText1.text
txt = txt & vbCrLf
rchText1.text = txt

and various other combinations (including TextRTF) with to avail. Any ideas to point my nose in the right direction?

Thanx, TonyP

Rich Text In Textbox
How do I get rich text in a text box?

Add Colored Text To Textbox Or Rich Textbox
Is there is script to make it add in a textbox the same text that is in the same text box plus some other colored text. eg

Before:

Code:
text

RichTextBox1.Text = RichTextBox1.Text + textFormated(&Hff,"lol")
After:

Code:
textlol

RichTextBox1.Text = RichTextBox1.Text + textFormated(&Hff0000," test")
After:

Code:
textlol test

*Challenge* Rich Text Format In Crystal Report Viewer
I am actually writing my text data in the Rich Text Box of VB6. I have given buttons to do some formatting like 'Bold', 'Tab' etc. for the Rich Text Box data like MS WORD. The data is then saved in the Access Data Base in RTF format. When I retrieve the data from the Access data base to VB6, it is OK. But when I retrieve the same data in Crystal Reports 8.5, then CR is not able to interpret the data correctly. The text is OK but the formatting is disturbed.

Move Data From Datagrid To A Rich Text Format File
i wanna copy data shown in datagrid to a rich text format file
as a report to be printed
please elaborate a bit

thx....

Need You Help On Adding SQL Server Field On Rich Text Box And Retrieve It Later
Hi Guys!

I need your help on this. You see, I have a form that looks like the attached file. It sets up an email template to be used for automatic email sending. In here, we set the subject, attachment, importance, body, etc. I'd like to add something(not sure what control to use) in the green colored space that will allow me to add a field from my SQL Server database(i.e. contact name) and incorporate it in the email body as shown in the attached file. Then, when the program is run, it will automatically send an email to those persons in the contactname field. I really don't have an idea how to do this. Please help me. I haven't encountered similar projects before. Also, my problem is how to put the selected field(i.e. contactname) to the rich text box in the right position(i.e. after the word Dear). Please help me Guys.

Thank you.

Regards,
BarberCut

Adding Hyperlink Capability To Rich Text Boxes
I've looked but come up dry. Where do I find the tips?

What Box To Use For Containing Pictures And Text? Rich Textbox?
what box do i use use for containing pictures and text? rich textbox? or something else? please help me, thankyou for your time

Centering Text In A Rich Textbox
Centering Text in a rich textbox.

Is that possible?

Rich Text In Textbox Control
Is there a way to rich text format a textbox control in MS Access 2002? I'm using the textbox to enter text for the body of an email, and I want to bold, italicize, etc. I might even want to add pictures. Is there another control I should use instead?

Thanks.

- bungee41

Coloring Rich Textbox Text
Hello everyone!
I'd like to set the default font color of a rich textbox. Since there is no 'text color' property for the control, I suppose it would be necessary to use windows APIs.
I already checked the FAQs, & I know how to color selected text; however my idea is that the code line:

        rtb1.seltext = "text I want to print" & vbcrlf

prints the text I want in a color previously defined.
Please help me, I'm kinda desperate...
Thanks in advance,
Marx

Copyright © 2005-08 www.BigResource.com, All rights reserved