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




How To Read Rich Text Box Content Line By Line


Hi all. I got a rich text box and i wonder how i can read each line of it one by one. For example i want to read each line of it and display it in massage box.
Furthermore, if i have 10 line of content in textbox how i can refrence each line and display it in massage box?

I be happy if some one show me how this can be done.Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Read Line By Line Of Text File And Move Content To Excel Record By Record
Hi,
   i am trying to move the selective information in the text file to Excel sheet record by record using VB.Can u help me in this regard.

The contents in text file is like:

"http://www.commerx.com/contact.html","inforequest@commerx.com"
"http://www.commerx.com/contact.html","ClientSupport@commerx.com"
"http://www.commerx.com/services-intranets.html","intranets@commerx.com"
"http://www.davacosourcing.com/company/","bignews@davacosourcing.com"
"http://www.davacosourcing.com/company/","careers@davacosourcing.com"
.
.
.
.
.
.

The above information need to be moved in Excel sheet record by record as:                    
http://www.commerx.com/contact.html        inforequest@commerx.com    
http://www.commerx.com/contact.html        ClientSupport@commerx.com    
http://www.commerx.com/services-intranets.html    intranets@commerx.com    
http://www.davacosourcing.com/company/ bignews@davacosourcing.com
http://www.davacosourcing.com/company/ careers@davacosourcing.com
.
.
.
.
..

Please do help in this regard as there are more than 1000 information that has to moved in the above pattern.

Thanx
babu


 

Read Line From Rich Text Box
Hello,
I am trying to read text line from RTB. This is similar as I read line by line text from file with line input command. I have to copy each line to new RTF BOX with addding some symbols and extra lines.
for example

"this is my name" is first line in RTF box
"This is your name" is second line

I want to produce new RTF as follows

----
this is ( my) name.
----

----
(This) is your name.
----



so I have to create 4 lines in new text box for each line in old text box..

I need to know how can I get one line from RTF box.

Thanks

Line By Line Text File Read And Correct Each Line
Can anyone help me create a small program or have any pointers
on pieces of code that reads a text file from folder "unfixed" then
fix the contents and then store the corrected contents
in another folder "fixed" and then move the file in folder "unfixed" to folder "old"

Details of contents.
There is a space infront of each line that should be removed.
Between the first group of numbers and the second there should be a zero for every space.
Then after the second group of numbers there should be just one space and the rest trimed off.


011531015222360000500355 3350505212004 50122
011531015222360000500363 5336305212004 6255
011531015222360000503465 2404505212004 50022
011531015222360000503463 1345205212004 50025
02153101522236 13 1503256


The @ symbol represents where a space should be.
I would like to read the file and then correct it and then
place the fixed contents in another folder with the original name.
Below is how I would like it to look.

01153101522236000050035500000003350505212004@
01153101522236000050036300000005336305212004@
01153101522236000050346500000002404505212004@
01153101522236000050346300000001345205212004@
021531015222360000000013@

Reading Rich Text Box Line By Line
Dear All,

I have a rich text box on my form

I have put the contents of a file in that

Now I want to read the contents of that text box line by line
instead of reading that file again.

How can I do that

Please help

thanks

abhay

How To Write Line By Line In A Rich Text Box???
Hi

I have three strings and a RichTextBox..

I want to add these three strings line by line:-

String1
String2
String3


How can I do such thing?


Thanks!

Line Input #1, Line...how Do I Read Ahead One Line (or Back Up One Line)
I am loading a file line by line using the LIne Input but at one point i need to look ahead at the next line to decided what to do on the current line...how do i look ahead one line? or how do i use the line Input function and then back up? Any help would be greatly appreciated.

Shane Thomas
p.s. please email replys in addition to the reply of post too
shathoma@nmsu.edu

Read, Find A Line And Delete The Line In Text File
Hi, I am writing codes to do the following things: read a line from a text file, if this is a matched line, delete the line and go to the next line.

Can any one give me some direction? Such as access mode, method to use, etc.

Thanks.

.Input ( Read Contentsof Text File - Line By Line )
I'm trying to import Data from a text file, which includes the following,

Vessel Name
000115600
000025600
000000000
000089000
000019000
000000000
6670.43

The above file is updated every five minutes and I wish to retreive this data in
order to perform calc's and then display a completion time for a process on the
User Form.

code:-----------------------------------------------------------------------------
---
Open "YourFile.txt" For Input As #1
While Not EOF(1)
Input #1, YourVariable
List1.Additem YourVariable
Wend
Close #1
--------------------------------------------------------------------------------

Instead of adding to a list as in the above example, I want to process it Line by
Line ( How do I achieve this using .Input ).

Help

How Can I Read One Line By One Line From A Multiline Text Field ?
i have a few rows of data on the text box

is there anyway to do this ?

Read A Word In A Line Of Text And Delete That Line
I have some aim logs that I'm going to put in .txt format, and I want to be able to delete the text that the other person has written.

Is there a way for me to specify a screen name and have the program delete that line of text?

Thanks,
Brad

How Can I Read Only One Line Or Specific Line Of A Text File
How can i read only one line or specific line of a text file?

How To Read Text File Line By Line?
Dears Friends,
I am coding a program to read emails.
Is there a way to read the email body text line by line ? if not possible, how can I set the bodytext to a text file and use that text file to read line by line?

Here is my psuedocode for reading email line by line:

With .bodytext
Loop from line 1 to EOF
If line x has string "Hello" then
If line x + 1 has "Money" then
forward this to youare@somewhere.com
end if
end if
End loop
End with

Here is my psuedocode for set .bodytext to file.
dim sFirststring as string
dim sSecondstring as string
With .bodytext
save the .bodytext to a file name A.txt
sFileName = " C:A.txt"
Open sFileName For Input As #1
Do Until EOF(1)
Input#1, sFirststring, sSecondstring
If Mid(sFirststring, 1, 1) = "Hello" Then
If Mid(sSecondstring, 1, 1) = "Money" Then
forward this to youare@somewhere.com
End IF
End If
Loop

Thanks,
Bil

How To Read Text File Line By Line ?
I want to read Text File line by line until EOF. How can I do it?

Read A Text File Line-By-Line
I have a text file, and I want to read each line at a time.

Read Text File Line-By-Line
I need to take a text file, read it line by line, and put certain lines into an array...

I need some help on the reading line by line part...

Can anyone steer me in the right direction? I don't need to read it all into an array, just 1 line at a time, and if the line meets certain criteria, put THAT LINE in an array...(I can handle the "if it meets certain criteria" part...)

Thanks!!

Read Text File Line By Line Through VB
Dear

I want to Read Text file through Vb.

How To Read Text And Use It Line By Line
Hallo everyone,
I need help if its not so hard.
I am in a challenge site and one mission is to make a brute forcer
for a page like this www.site.com/../../../password=

I need a part of this project

So...
1) how can i make a button to read a .txt file and pass it into a listbox or anything else (excel or sth i dont know) in the form?

And after that
2) how can i make the program read the listbox line by line?

Thanks in advance for your time.
Greets

Reading Textbox Content Line By Line
Hi, i have a text file with encrypted content, i'm currently openning and decrypting all the text file into a textbox. Now, how can read the textbox line by line, similar to reading an external text file?

I know how to do it with an external text file, but that will require to decrypt the file in the user computer and that's exactly what i want to avoid.

Here is some code i used, but not what i currently need!!

Code:
Private Sub Process(FileName As String)
On Error GoTo errorHandler

Dim StringData As String
Dim nFreeFile As Long
Dim temp, strFileName
strFileName = ""
nFreeFile = FreeFile

FileName = App.path + "EncryptedText.Text
Open FileName For Input As #nFreeFile

Do While Not EOF(nFreeFile)
DoEvents
Line Input #nFreeFile, StringData

'A few lines of code here

Loop
Close #nFreeFile

Exit Sub

errorHandler:
MsgBox Err.Number & " " & Err.Description
End Sub


I'll appreciate any help!! thanks
2005

Printing Text Box (muti-line) Content
Hi

ok i'v search the forums and took a look in the FAQ

i'v never even tryed to send stuff to print from VB so...

what i'm looking to do is say..

Print "Printed By AAO Desktop Admin" & vbnewline
Print "=============" & vbnewline

then i want it to print
"exec " then the first line of the text file... then move onto the second line
"exec " second line

and so on and so on.

now i can work out how many lines the text box will have if i need to so that will not be a problem.

but dose anyone know how i would do this?

remember this is my first attempt and pritting

cheers

Rich Textbox - Making A Given Line The Top Line Displayed
This is the short-and-sweet version of a question I posted earlier. Is there a way to make a given line in the rich textbox the first line displayed? (For example, if I want to display line #53 as the top line, is there a combination of methods/properties I can use to do this? I can't find any obvious technique.)

New Line In Rich Text Box
Guyz,
i got a problem here,
actually, it is pretty simple.
i want to insert a new line in richtextbox by using the VB programming code.

for example,
i have richtextbox1 and command1,
and i make this code :

private_sub command1_click

richtextbox1.text = "abcdefghijk" & "lmnopqrstu"

end sub

the result when command1 is clicked :

abcdefhijklmnopqrstu

what i want is to put the "lmnopqrstu" on the next line, like this :

abcdefghijk
lmnopqrstu

can anyone help ?

i know it is pretty simple, but i need the answer,
please reply...

How To Get First Line From The Rich Text Box
Pls. Tell me how i can get first line from the Rich Text Box Control ???

Next Line In Rich Text Box
How can I start a new line in Rich Text Box using VB6?
Also, I want to ask whether I can set the rich text box to fit the size of an A4 paper so that I can print it later.
Thank you for your help.

Replacing A Line Of Text With A Blank Line, Then Delete That Line
The code below works perfect, retrieving the string of text that the user selects from the listview. Then I do bla bla bla. What I want to do is convert this so that the the user selects a string from the listview which corresponse to a string in the file. then click remove. my problem is, how do i remove a line of text from a text file? if i open for reading i cant modify the contents, if i open for writing it erases the data. and i dont want to write the data into a string, parse out the string that i don't want then rewrite the file.... that could be....not so good...

---------------------------------------------------------------------------------
'the line that actually is in the file..
email=gmatteson@myemail.com
i want to remove this line...
---------------------------------------------------------------------------------
Dim strSelected As String
strSelected = lvwAccounts.ListItems(lvwAccounts.SelectedItem.Index)

Dim objFSO As New FileSystemObject
Dim objFile As File
Dim objTS As TextStream
Dim strReadline As String
Dim strFind As String
Dim strData As String
Dim strEmail As String
Dim blnFound As Boolean

Set objFile = objFSO.GetFile(App.Path & "pop3a.txt")
Set objTS = objFile.OpenAsTextStream(ForReading)
Do Until objTS.AtEndOfStream Or blnFound = True
'reads line in file
strReadline = objTS.ReadLine
strFind = "="
strData = (InStr(1, strReadline, strFind) + 1)
strEmail = Mid(strReadline, strData)
If strEmail = lvwAccounts.SelectedItem.Text Then
frmEdit.txtEmail = strEmail
blnFound = True
End If
Loop
---------------------------------------------------------------------------------
Thanks,
- Gabe

Reading The Content Of A Text File Via Line Input, Backwards!
I am using Line input to read the content of a txt file into a listbox. As each line is read in, a function is called upon to check for something. It would be very helpful if I could read the text file in reverse, so the first line is read last.

Is there a way to do this?

Thanks!

Save Last Line In Rich Text Box
I have a Rich Text Box in which I load a log file (text file) for viewing & editing purposes. I would like to be able to save the file that is currently displayed as well as write the last line( the last line only, the line that the operator appended with a time stamp of completion), to be appended to the end of another text file file, that will be printed & cleared on a weekly or monthly basis.

To save the currently displayed file I use
rtbWindow.SaveFile "c:log.txt", rtfTEXT

How do I save the last line edited to another file?

Get Last Visible Line From A Rich Text Box
does anyone know how to find out what the last visible line in a rich text box is? Theres an API function to find the 1st visible line, but I dont know how to go about finding out what the last visible line is? I need it so that I can generate my own "page up" and "page down" messages to send to the richtextbox, since Im trying to emulate the "non-smooth scrolling" of a regular textbox, and the page up and page down buttons are scrolling smoothly and creating a problem.

If I know what the 1st and last visible lines in the textbox are, then I can just generate a generate a "page down" routine as being "scroll down (#of visible lines) + 1", same for page up, kinda.

Please help.

Deleting The Last Line Of Rich Text Box?????
I need the Code to Delete the last line in a Rich Text Box. dont have a clue how to do this




halforc

Line Spacing In A Rich Text Box
How can I vary the vertical line spacing in a Rich Text Box to which I;m writing data for display. I'd like to move the lines a bit closer together to squeeze a few more into the display.

I'm making the display by appending text plus the occasional vbCrLf.

Truncate Top Line(s) Of Rich Text Box
Hello

I have a Rich Text Box Control that I want to limit to 5000 lines.

I would like, when the 5001st line arrives, to discard the top line.

Is there an easy and elegant way to do this.

Clearly, I could look for the first vbCR:

rtbMain.selStart=instr(rtbMain.Text,vbCR) + 1
rtbMain.selLength=99999999
rtbMain.selRTF=rtbMain.selText
rtbMain.selStart=99999999

The problem with this is that it's inefficient and, more importantly, the RTB jumps to the top and back which looks horrible.

Any help would be much appreciated.

Thank you.

First Character In A Line (Rich Text Box)
So when someone types a word into one text box it will go to that word in a rich text box like a find function. This works but I want it so that it only scrolls to that word if it is on it's own line, like for example you type in "precious" but it goes to the first example of it which is "nonprecious". So i want it to go to precious which is on its own line.

Line Spacing For Rich Text Box
Hey,

I'm new to the rich text box component in Visual Basic 6. I want to add line spacing to the rich text box for my little chat program just to make it look better. Explanations on the internet are very confusing but I managed to get some information, but I don't know how to use or format the text box.

Force New Line In Rich Text Box
How do I create a new line in a rich text box. Say I have the code below and want a new line to be between each segment of text between " "


VB Code:
NOTAMtext.Text = "Q)EGTT/QMXLC/IV/NBO/A/000/999/5227N00145W005 " _& "B)06/01/09 23:00 UTC C)06/03/24 06:00 AGA (C0104/06) " _& "D)SUN 2300-2359, MON-THU 0001-0600 AND 2300-2359, FRI 0001-0600 " _& "E)TWY E CLOSED BTN E3 AND E6 DUE WIP, SUN TO THU NIGHTS 2300-0600. " _& "TWY D BTN D4 AND D5 TEMPO UPGRADED TO CODE E TAXILANE. WING TIP " _& "PERSON AVBL FOR ALL CODE D AND E MOVEMENTS."

Rich Text Box And Line Break
I have an RTF file with section line breaks in it, I am scanning and replaceing various bits of text, however when I savefile, the linebreaks are gone, is there any way to either save these or insert new ones.

simon

How To Insert Bar(line) In Rich Text Box
please help me how to insert bar in the rich text box
thank you
naveen

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.

Rich Text Box, How To Get The First Line Bold?
Anyone have a simple way of determing the length of the 1st line in a rich textbox and making it bold, and any other lines nonbold and/or another color?

Example:
Line1: Monday, December 25, 2000
Line2: Christmas Day!

Thanks,

What Line The Cursor Is On In A Rich Text Box?
Is there a way to find out what line the cursor is on in a rich text box? I know you can get what the position is, but I want just the line.

Extracting A Line From A Rich Text Box
How would I extract 1 line from a rich text box, make some changes to it using a sub that i already wrote, and then put it back where it was with the changes.

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

Add A Character To The End Of Each Line In Rich Text Box
How do I add some characters to the end of each line in a rich text box? I was thinking something like replace text1.text, vbCrLf, "abc" would work, but of course, it does not.

Any ideas??



Edited by - Marce22 on 1/2/2005 10:21:43 PM

Rich Text -vertical Line
How to draw a dynamic bold vertical line in richtext? its something like outlook.When you reply a mail a default bold vertical line are displayed on the left.thanks!

Retrieve Content Line By Line From A RTF
Can someone help me with this!!

After loading a document in a RichTextBox control, How can I retrieve the content line by line and store them in an array. The line has to be split at the place where it wraps and not at every hard return.

Thanks in Advance,

Rama

Return String For A Line On Rich Text Box
how can i return what ever is on line 12,224 on a rich text box? eg:

mystr = line(12224 ,text1)

kinda thing

Inserting A Line Break Into A Rich Text Box.
I want it to leave one line inbetween the first and the second. My current code looks like this:

output.text = "This is on the first line"
output.text = output.text + " "
output.text = output.text + "This is the third line"

How can I do that?

Rich Text Box Problem, Extra Line
im opening a text file and putting it in a richtext box. this is the way im putting it in the box.

[code]
Do While EOF(2) = False
Input #2, temp
mainText.Text = mainText.Text + temp + vbNewLine
Loop
[code]

the only problem with that is that it adds an extra line because after the last line is read it still adds a vbNewLine.

one way i thought of fixing this is just to simulate a backspace after the richtextbox is filled, but i dont know how to do that.

Rich Text Line Number Question
Hi all.

How can I make a RichText Box display changing line numbers as the box is scrolled?

There has got to be a way to detect when a new line enters a Rich Text box and what that new line number is.

I want to have label1 display the changing chapters in a book as the rtf box is scrolled without having to click on the box to retrieve a cursor position.

I want the numbers to change automaticaly in label1.
Of course my code would reflect that chapter 1 is between line numbers 0 and whatever. etc.

Anybody Help!

Line And Character Position In Rich Text Box
Hello Group,
I'm trying to use the Microsoft Rich Text Box control as the basis of a basic text editor.  I'm also using a Status Bar control in the form and I'd like to provide the line and character position of the cursor in the status bar.  Getting the (absolute) character position is easy with the SelStart property of the RichTextBox control.  However, I've been having difficulty trying to break that down into the line and the relative character position.  This is the code that I've written so far:

CODEPrivate Sub GetPosition()
    
    Dim strCAMS() As String
    Dim intCount As Integer
    Dim lngCount As Integer
    Dim lngLine As Long
    Dim lngChar As Long
    Dim strTest As String
    Dim intTest As Integer
    Dim strCharTest As String
    
    strCAMS = Split(Me.txtAddCams.Text, vbCrLf)
    
    intCount = 0
    lngCount = 0
    
    For intCount = LBound(strCAMS) To UBound(strCAMS)
    
        If intCount = LBound(strCAMS) Then
            intLineStart = 1
        End If
        
        intLineEnd = intLineStart + Len(strCAMS(intCount))
        
        lngCount = lngCount + Len(strCAMS(intCount)) + 2
        
        If (Me.txtAddCams.SelStart >= lngCount) And (Me.txtAddCams.SelStart <= lngCount) Then
            
            strTest = Mid(Me.txtAddCams.Text, lngCount, Len(strCAMS(intCount)))
            
            For intTest = 1 To Len(strTest)
                strCharTest = Mid(strTest, intTest, 1)
                
                If Asc(strCharTest) < &H20 And Asc(strCharTest) > &H7F Then
                    lngCount = lngCount + 1
                End If
            Next intTest
            
            If strCAMS(intCount) = strTest Then
                lngLine = intCount + 1
            
                lngChar = (Me.txtAddCams.SelStart - lngCount) + 1

                Me.sbStatusBar.Panels(Panels.Line).Text = "Line: " & lngLine
                Me.sbStatusBar.Panels(Panels.Char).Text = "Char: " & lngChar
            End If
            
            Exit For
        End If
        
    Next intCount
    
End Sub

Coloring Only The Current Line Of A Rich Text Box
I am making a chat program and in the chat box where the text appears i want it to be different colors for the different types of messages. the problem i hae is coloring only the line of text and the whole line of text.
I want the box to look something like this:

Jay320: hey man
Mike345 tells you: great

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