VB6, RichTextBox, Lines?
Does anybody know how to make the cursor thats in a richtextbox move to a certain line that the user types in a text box? What if the Richtext is full of text and has vertical scroll bars?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Lines In A RichTextBox???
In a little project I'm working on I have report which is printable and viewable on the screen (in a RichTextBox). The person who'll be using the reports has requested a space on the Report for them to jot notes. What they would like is squres/grids scattered arount relevant bits of info on the page for them to scribble in.
To do this I need lines. How (if possible) do you put lines in a RichTextBox??
If it is impossible can someone suggest and alternative control to use. All I really need is some fonts to make it look pretty, tabs to arrange it and these * * * * lines!!
Richtextbox Not Displaying All Lines.
The rtf box is only showing the last line of the text file that is being read into it. I've tried adding vbcrlf, and it still no workie. I have the box set to multiline. Save me from my own stupidity!
FF = FreeFile()
Open "C: empWe_are_moving Email_addresses.txt" For Input As FF
Rem strTextfile = Input(LOF(FF), #FF)
Do While Not EOF(FF)
Line Input #FF, strTextfile
If InStr(1, strTextfile, ",") = 2 Then
strTextfile = Mid(strTextfile, 3, 50)
Rtfbox.TextRTF = strTextfile
Adding Lines To RichTextBox 6.0
I would assume this is a easy question, and I'm just being stupid about something...
I'm inputing lines from a text file into a Rich Text Box, and want them to appear with the same line breaks that are present in the text file. I've tried adding chr(13) to the end of each input string from the text file, and that sort of works, but it adds a full space between each line, instead of just a single carriage return.
Any ideas? Should I be using another ascii value? (even though I hope I'm not cause the box later re-saves to a file and looks for chr(13)'s to make spaces in the text file)
I'm not too famililar with RichTextBox, so maybe I'm doing something wrong there.
Thanks for any help,
Array Of Richtextbox Lines
I need to take the contents of a richtextbox and put each line into an array. I searched for "Wordwrap" and found nothing there that helps. From what I read something like this should work:
dim TheArray() as string
TheArray = split(RichTextBoxTextVariable, vbcrlf)
All this gives me is an array with a single line (The whole contents of the textbox) in it. I need an array with each line of text as an element. Anybody?
Color Lines Of RichTextBox
Hi, I have this richtextbox where I'd like to color an entire line of it a certain color whenever I see a certain word.
For example, if I type in "Hello, how are you today?" Let's say "you" is the word I'm looking for. When it finds this word, I'd like it to color the line blue, but the actual word another color like red.
Like this. "Hello, how are you today?"
Anyone have any ideas? I know I need to use SelLength, SelColor and what not, but not sure how.
Draw Lines In RichTextBox
I cant seem to get this to work...
Maybe im doing something wrong.. but essentially I want to draw a light gray line above or below occurences of certain words...
How can I do this?
Removing Lines From A RichTextBox
Basically what the title says. I want to remove the first line if the number of lines in a RichTextBox exceeds 500 logical, but everything I tried sets all text color to white (although it does retain the text after the second line).
Deleting First Four Lines In A Richtextbox *****
i have some data comming from a micro processor in the data there r some tags and information that i'm removing using replace but then it leaves blank lines in the text files.so the question is how can i remove the first 4 lines in a text file ?
thanks for your help !
Richtextbox Vbkeyup And Down Lines
im hoping one of u could help me with this im trying to fiqure out how to move directly down and up in a riuchtextbox like lets say ur text cursor is 10 characters in then u hit down i dont want it to go toi the begining of the next line but to 10 in the next line and if u where in lets say 4 and u hit up ud go to 4 on 1 line up.
thanks for your time
Drawing Lines In Richtextbox
I am trying to draw a division line in a richtextbox. I tried using underline, but it doesn't work when there is superscript or subscript font. Any suggestions?
RichTextBox - Restrict Number Of Lines
I'm using the following code to restrict number of lines in a word-wraped RichTextBox. It adds blank lines if there are less number of lines than m_AllowedLines. And deletes unwanted lines. I'm calling it from RichTextBox_Change event.
The problem is it doesn't work if user pastes using Ctrl+V. After user's pasting job , calling this sub doesnot removes unwanted lines. Can any one please help me ?
Private Sub RestrictLine(m_AllowedLines As Long)
Dim strTmp As String
Dim i As Long
Dim lngOldSelStart As Long
Dim lngOldSelLength As Long
Dim boolOldHideSelection As Boolean
Dim lngMaxLine As Long
Dim lngLastLineStart As Long
lngOldSelStart = rtfDoc.SelStart
lngOldSelLength = rtfDoc.SelLength
boolOldHideSelection = rtfDoc.HideSelection
rtfDoc.HideSelection = False
lngMaxLine = LineCount
strTmp = ""
If lngMaxLine = m_AllowedLines Then 'OK
ElseIf lngMaxLine < m_AllowedLines Then 'Add blank lines
For i = 1 To m_AllowedLines - lngMaxLine
strTmp = strTmp & vbCrLf
rtfDoc.SelStart = Len(rtfDoc.Text)
rtfDoc.SelLength = 0
rtfDoc.SelText = strTmp
rtfDoc.SelStart = lngOldSelStart
rtfDoc.SelLength = lngOldSelLength
Else 'delete extra lines. not working if user pasts text
rtfDoc.SelStart = GetLineStart(m_AllowedLines - 1) + GetLineLength(m_AllowedLines - 1)
rtfDoc.SelLength = Len(rtfDoc.Text) - rtfDoc.SelStart
rtfDoc.SelColor = vbRed
RichTextBox - Remove Duplicate Lines
I tried to do this using some code for removing duplicates in a listgbox, but I couldnt get it to work.
Anyone here have some code offhand that takes care of this?
Thanks ahead of time.
Get Place Of Typer In Lines In RichTextBox
I want to get the place of the typer icon (The "I" icon) in lines.
For example, if the user typed 3 lines and now his in the fourth (4) line i'll get the number 4
How can i find where is the I thing in lines?
How To Remove Extra Lines From Textbox Or RichTextBox
How To Remove Extra Lines From Textbox Or RichTextBox?
my TXTBOX look's like
How can i make it look like
i am pissed @ this plz help !!
Slow Loading Lines Of Text Into An Richtextbox
I'm loading a log file from a game into a rich text box, and on slower machines a 500kb file can take up to and over a minute.
It's not exactly the loading that takes time it's the coloring the lines. I originally loaded the file coloing the lines as it went then I thought it would be a little more efficient to load the file into a string array then color it... which I did, however there is no noticable speed difference.
There are about 17 different possible colors (which I trimmed down as much as possible) depending on what type of message the line is (determined by an integer at the begining and in a certain case that line will have another delimiter that will have 9 different colors)
I was wondering if there are any ways to better optimize my code...
Public Sub ColorLog()
Dim MsgType As String, SysMsgType As String
Dim MyFileLen As Long, MyInputLen As Long
Dim counter As Integer
MyFileLen = FileLen(FilePath)
pbar.Max = MyFileLen 'initialize progress bar
For counter = LBound(Data) To UBound(Data) 'from the start of the array to the end
MsgType = Mid(Data(counter), 1, 1)
Select Case MsgType
Case 0, 1 'Public and public macros Chat
rtf.SelColor = vbCyan
Case 2, 5 'Private/System Message
rtf.SelColor = vbGreen 'Default system color
If MsgType = 5 Then 'If it's extra system message color type
SysMsgType = Mid(Data(counter), 5, 1)
Select Case SysMsgType
rtf.SelColor = vbRed
rtf.SelColor = &HC0&
rtf.SelColor = &HFF00FF
rtf.SelColor = &HC000C0
rtf.SelColor = vbBlue
rtf.SelColor = &HC00000
rtf.SelColor = vbWhite
rtf.SelColor = &HE0E0E0
rtf.SelColor = &HC000&
Case 3 'Team Chat
rtf.SelColor = vbYellow
Case 4 'enemy team chat
rtf.SelColor = &HC0C000
Case 6 'Personal Chat
rtf.SelColor = &HC0C0&
Case 7, 9 'Squad and Enter/Leaving
rtf.SelColor = &HFF80FF
Case 8 'Killed/Killed By Messages
rtf.SelColor = vbRed
Case Else 'If it's extra info, not actual part of log
rtf.SelColor = vbWhite
If MsgType < Chr(48) Or MsgType > Chr(57) Then GoTo NonMsgType 'If not actual part chat log.
If mnuFilter(MsgType).Checked = True Then 'If the user has chosen to filter this type of message
rtf.SelText = "" 'don't show it
rtf.SelText = Data(counter) & vbCrLf 'Print to richtextbox
MyInputLen = Len(Data(counter)) 'update approx size of data entered
pbar.Value = pbar.Value + MyInputLen 'update progress bar
pbar.Value = 0 'reset progress bar when done
Public Sub OpenLog(c As String)
Dim counter As Integer
rtf.Visible = False 'Hide richtext box for faster loading
rtf.TextRTF = "" 'clear existing text
FilePath = c 'update filepath, can be from open dialog or commandline arguement
If FilePath = "" Then Exit Sub 'If filepath is abort process
Open FilePath For Input As #1
ReDim Data(counter) 'Dyanmically alloc 1 space to begin with
Do Until EOF(1) 'loop until end of file
DoEvents 'do anything that needs to be done
Line Input #1, Data(counter) 'add line to to array
counter = counter + 1 'update counter
ReDim Preserve Data(counter) 'allocate one more stapce
Close #1 'close file
Delete Trailing Empty Lines In RichTextBox
Ok if I have a richtextbox on my form which has the following text:
How can I turn it into:
without loosing the formattings?
Basically I need to delete all the trailing empty lines, but I'm not sure how. Please help!
How To Find Out The Fontcolor Of Lines Inside A RichTextBox
got a question to ask you folks...
I know that for setting the color of a Richtextbox, I just use the follow command:
RichTextBox1.SelColor = RGB(255, 0, 0) ' which will select RED
however, after I have changed the font color for that particular line to RED, how can I detect/know that the font color for that particular line is RED?
I wanna detect this becoz if I were to doubleclick that red line again, I wanna change it's font color back to black.
RichTextBox,WordWrap And Return Separated Lines
i have set the property
WordWrap = true
so the lines are automatically
get wrapped .
But i want to treat the next line
also the same line ..
for example :
1. This is first line
and this line also first line
and this also first line .Oh (Press enter key here)
2.This is actually the second line and
this is also same line (Enter key)
3.This is the third line.(Enter key)
4.This is fourth line.
How to do this ?
any help ..please this is urgent.
code snippets in any language is appreciated.
Reading Certain Lines Of Files And Outputting Those Lines
This is what I am trying to do and I think I am going about it all wrong.
I am trying to read a log file (ascii) and only want to read in certain pieces of information (e.g. a failed request for a web page) and then I want that information written to a new file.
I wont even attempt to post thw code I have trying to work with, if someone can give me some pointers of post some example, I would really appreciate it.
Hmm - New Lines Arent Read As New Lines By Vb In A File
Heres the situation
im using urldownloadtofile to download a text file from the internet onto the harddrive. although the textfile on the net has 5 items, each on a single line, when i use that function the file saves as 5 items all on a single line.. and where a new line is supposed to be, i see a "box" in notepad..
needless to say, when i try to load the file into an array using Line Input, all 5 items are on a single array number, instead of one item in each array number..
heres what i mean..
text file online:
text file when downloaded to hd:
the box is interesting, if i copy the entire text from the file on my hd and paste it, they paste with all 5 items on seperate lines..
my question is, how can i load abcde with one item in each array with VB? line input wont work cause itll store abcde in one string
Read Lines And Count Lines From Txt File - Thank Ye All
im back for some more help, so i hope you guys can.
ive had a quick search on the forums for this but cant find anything that helps, so heres my problem:
i have this code:
Dim lines As Integer
Dim current As String
lines = 0
Open "C:files.txt" For Append As #1
Do While Not EOF(1)
Line Input #1, current
lines = lines + 1
txtFILE = lines
but that code doesnt work, it does count the lines at all, i get no msgbox's, no count, no nothing.
any help would be much appreciated.
I'm all wrapped up in my binary blanket and I'm coding on late into the night
Edited by - Primary_Slave on 11/4/2004 9:46:42 AM
Moving Lines In A Text Lines
I am creating a replay for a game and I am keeping the info for it in a text file but after 5 seconds I want to clear out anything over 5 seconds old and continue to add. I can figure most of it out cept for the whole part about it removing the first line and moving the rest of the lines up. I am adding to the file every 1/2 second for 5 seconds. Heres what I have so far....
eplay.txt" For Append As #1TotTime = Int(Timer) Print #1, Int(Timer); "lblbox(" & Index & ")"If Int(Timer) - TotTime = 5 Then
lol, not much but I can't figure out how do move the lines. Would I just kinda have a second file and copy the lines into the new file and just clear out the old one and so on? But that doesn't seem like an appropriate way to go. Any help with this situation would be muchly appreciated. Thank you and good day.
Keep The Color Of Richtextbox.text On Copy To Another Richtextbox
So, i have 2 richtextbox controls and the text in one of them is colored with different colors (per words like vb editor).When I copy the text to another richtextbox, I lose the colors.How can I keep the colered words?
Does anybody experienced this?
Scroll Richtextbox Send Each Line To Another Richtextbox
Well this what I want to do, lets say I have a Multiline Richtextbox1 And I want to send each line from Richtextbox1 to Richtextbox2 one by one untyl it hits last line. And in doing so it keeps the RTF format of richtextbox1 in richtextbox2.
Like this will be the processes,
There 3 line in richtextbox1,
Take line 1 of richtextbox1 sends it to richtextbox2,
Take line 2 of richtextbox1 sends it to richtextbox2
How Many "visible" Lines (including Wrapped Lines) Are In A RTB?
I know I can get the "total" number of lines (including wrapped lines) in a RichTextBox by doing the following:
Code:SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
but, how can I get the total number of "visible" lines (including wrapped lines) in a RichTextBox only (ie: only the lines currently able to be seen in a RTB)?
Edited by - uncletr on 1/16/2007 5:27:03 AM
Lines Events Lines Ocx
I would like to create lines with vb6 and to change them when my program is runnig, but "line1" doesn't have any events, not mouse_clickmouseover.
I'm looking for solution for that problem or lines ocx instead.
Hope for answers...
How To Copy A RichTextBox To A RichTextBox
Good Day Guys!
How will i copy the text of one RichTextBox to another RichTextBox with the exact text format?
Please help me if this is possible...
Thanks alot in advance guys!!!
Adding TextRTF Without => RichtextBox.textRTF = RichTextBox.textRTF&&newpart RESOLVED
I'm making a project that uses Richtextboxes
When I want to add new code to my project I do it this way :
previous = RichTextBox1.TextRTF
leftside = Left(previous, Len(previous) - 6) 'removing the "par }" (will be added again later on)
RichtextBox1.textRTF = leftside & Newcodes & "par }"
This takes a lot of time when I use a lot of pictures because all previous data needs to be re-evaluated by the RichTextBox.
When NORMAL PEOPLE add text to a textbox they do it this way ...
RichtextBox.seltext = NewText
But this can't help me because I'm not adding text.... I'm adding RTF-codes (that can not be done with the RichTextBox standard properties).
But does somebody know how I can add RTFtext without having to read all previous RTFtext ?
How Can I Get Richtextbox Line And Richtextbox Line Count?
how can i get richtextbox line and richtextbox line count? i have the code to get textbox line and richtextbox line count (see below). but, it doesnot work for richtextbox control. what modification i want to make in the below code to work. help me....
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'Description: Get a line count for a Text Box
Global Const WM_USER = &H400
Global Const EM_GETLINECOUNT = WM_USER + 10
Global Const EM_GETLINE = &HC4
Function TextBoxLine(TB As TextBox, ByVal LineNO As Integer) As String
Const BUFLEN = 1028
Dim buffer As String * BUFLEN
' Set 1st 2 bytes to Buffer length
Mid(buffer, 1, 1) = Chr(BUFLEN And &HFF)
Mid(buffer, 2, 1) = Chr(BUFLEN &H100)
If Not TB.MultiLine Then
TextBoxLine = TB.Text
ret& = SendMessage(TB.hwnd, EM_GETLINE, LineNO - 1, ByVal buffer)
If ret& Then
TextBoxLine = Left$(buffer, ret&)
TextBoxLine = ""
Function TextBoxLinecount(TB As TextBox) As Integer
If TB.MultiLine Then
ret& = SendMessage(TB.hwnd, EM_GETLINECOUNT, 0, 0)
TextBoxLinecount = CInt(ret&)
TextBoxLinecount = 1
Firstly is it possible to draw a simple curved line in VB?
Secondly is it possible to specify a series of points through which a line of best fit can be made or alternately where the points can be connected via an interpolated line?
Alternately is is possible to highlight two points then draw a line related to an equation through it? (i.e. x^2) This is for the purpose of a simple drawing.
I would have done a search before posting but really do not know what the search criteria would be.
Ideally I would like to generate a line (for the purpose of a drawing) based on a combination of user inputs (coordinates) and a series of constraints.
Hope that makes sense
suggestions for either potential search criteria or how I might go about this would be greatfully received.
How Many Lines?
what is the best way to know how many lines a txt file is composed of?
PS: My lines are of course delimited by a Carriage Return + Line Feed.
Thanks a lot.
I'm creating a graphing program which obviously has a need for lines, but what I want to do is change the color of a line when it's created.
I'm using "Line (x,y)-(x,y)" to create the line, but the line is always black and I want a gray (&HC0C0C0) line.
Help With Lines
I want to do this:
start with a horizontal line
calculate the midpoint and lower that points y value
now I have two lines
find the midpoints for these lines and lower there y values
continue this for z number of times
I have problems though when I try to do this. I was going to use an array for the lines and store the x1 y1 x2 and y2 values for each line. But I think storing an array of points would be better and then drawing the lines. However I have trouble figuring out a way to calculate which points are formed from the other points and calculating the midpoints between all the points. Points 1 and 2 will be the ends of the first line, then point 3 will be the raides midpoint of that line. How can I do this using an array of points and then draw the lines from point to point, the lines shouldn't interesct and point 1 is not necessarily going to form a line with point 2, it might form a line with point 4 or even some toher number.
I know this explanation is a little messy but the top explanation might help you out.
And Now? How Many Lines Do You See!?
Okay. I've saved the moves made in a game to a text file. I know how to populate a listbox with the text file but I have a problem. Using for and next, I can only populate the listbox with files when I know how many lines there are.
for lines = 1 to 7
I want the hard coded 7 to be a dynamic variable that changes depending on the number of lines in the saved file as not all games will end in 7 moves exactly. So! I was wondering... is there anyway to have the program figure out the amount of lines in a text file prior to trying to work with it?
The only way I could figure out how to do it, would be to write the number of lines that are in the text file on the first line of that text file and making that the dynamic variable I'm looking for. I tried this and ran into a small error. I thought that a.readline moves down to the next line every time but in the case that I tried it didn't.
Is there a different way to do this or can it even be done!?
Thanks in advance.
how do i make a line longer in a code like
if keyascii = 45 then
'where line currently is n extends in the direction is it pointing n wont stop extending
basicly im asking how to extend a line up down left right and diagnola
Hi, i know when you program, you can keep all the code in your screen by using the '_ ' method, but is there anything you are supposed to do on the next line because my computer doesnt like it :S. and also in msgbox's, how do i put things on new lines?
How would i do this code with out it flickering?
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
For A = 0 To 10000 Step 100
Me.Line (A, 0)-(X, Y)
For A = 0 To 10000 Step 100
Me.Line (0, A)-(X, Y)
For A = 0 To Me.ScaleWidth Step 100
Me.Line (A, Me.ScaleHeight)-(X, Y)
For A = 0 To Me.ScaleHeight Step 100
Me.Line (Me.ScaleWidth, A)-(X, Y)
I'm not sure what subject this should go under but anways.
I have a document and I'm pulling out different lines and putting them into different text boxes.
Open "file name" For Input As #1
i = 0
Do While Not EOF(1)
i = i + 1
Line Input #1, lines
If i = 1 Then
a.Text = lines
ElseIf i < 80 Then
a.Text = a.Text & vbCrLf & lines
ElseIf i = 80 Then
PlayerName.Text = lines
ElseIf i = 81 Then
sqdname.Text = lines
ElseIf i = 82 Then
password.Text = lines
ElseIf i = 83 Then
b.Text = lines 'everything works to this point.
ElseIf i <> 83 Then 'what should this be? the lines from 83 to 120 have to be put in 1 text box.
b.Text = b.Text & vbCrLf & lines
ElseIf i = 121 Then
HostName.Text = lines
ElseIf i = 122 Then
c.Text = lines
ElseIf i > 122 Then
c.Text = c.Text & vbCrLf & lines
I know its probably a stupid question but how do you create those gray lines between icons? an example would be if you reply to this message, and look between the font selection and remove text formatting right under message:. i know there just lines, but how to you make them look the way they are. is it just a color, or is it in its properties?,
If I have Line1 and Line2 on my form, is there an easy way to see (with code) whether they intersect?
How can I determine the top of a line, because it
depends on it's borderwidth?
Lines In RTF
Does anyone know how to create text surounded by lines (such as tables in Excel) and control the thickness, linestyle in an rtf file?
Lines Lines Everywhere The Lines...
I am making a Module for my application, here is what I would like to accomplish:
When the user presses the 'Return' key, I would like the cursor to begin a new line as usual, but I would like to also enter the previous line (the line the user just ended) into a string. This way I can process the previous line and have the cursor react according to its contents.
I have tried various methods of doing this, many of which resulted in the cursor remaining in the same line after 'Return' is pressed. I also do not know how to get just a line of text... this will show me how to do both of these.
-"your mother was a hampster and your father smelled of elderberries."