[RESOLVED] blank line at end in richtextbox
I trying to add sentences on a new line to the end of text in a richtextbox
Like this:
with rtb
.selstart = len(.text)
.seltext = vbcrlf & "some new text"
end select
This works okay if there is no vbcrlf already in the text i am adding to.
If the text i am adding to has a vbcrlf at the end a blank line is added
before my new text.
How can i find if there is a vbcrlf and how to delete it ?
.
Re: blank line at end in richtextbox
vb Code:
if right(.text,2)=vbCrLf then .seltext = "newtext" else .seltext = vbCrLf & "newtext"
That should work, offhand
Re: blank line at end in richtextbox
Quote:
Originally Posted by smUX
vb Code:
if right(.text,2)=vbCrLf then .seltext = "newtext" else .seltext = vbCrLf & "newtext"
That should work, offhand
Than you
That would probably work i just need a way to select just the last line in the rtb
Every line above the last line will have a vbcrlf
Re: blank line at end in richtextbox
using strrev(.text,vbCrLf) will give you the point at which the list vbCrLf is, but you'd then have to do other stuff to check and see if the last line is empty or not...the suggestion I gave might be the best option...that or...
vb Code:
if right(.text,2)=vbCrLf then .text=left(.text,len(.text)-2)
Re: blank line at end in richtextbox
Quote:
Originally Posted by smUX
using
strrev(.text,vbCrLf) will give you the point at which the list vbCrLf is, but you'd then have to do other stuff to check and see if the last line is empty or not...the suggestion I gave might be the best option...that or...
vb Code:
if right(.text,2)=vbCrLf then .text=left(.text,len(.text)-2)
seems vb does not even see the vbcrlf i can see the 2 little squares in bread but
vb does not. I might have code against the rtf code directly.
Thought this was going to be easy
Re: blank line at end in richtextbox
Do me a favour and run this line of code...paste the results from the debug window here so I have an idea of what the problem is :-)
vb Code:
debug.print asc(right(.text,1)), asc(mid(.text,len(.text)-2,1))
I think the second part is right, not 100% sure...it should return the asc codes for the linefeed first then the carriage return...10 then 13
Re: blank line at end in richtextbox
Quote:
Originally Posted by smUX
Do me a favour and run this line of code...paste the results from the debug window here so I have an idea of what the problem is :-)
vb Code:
debug.print asc(right(.text,1)), asc(mid(.text,len(.text)-2,1))
I think the second part is right, not 100% sure...it should return the asc codes for the linefeed first then the carriage return...10 then 13
debug with vbcrlf
10 33
without vbcrlf
33 101
Re: blank line at end in richtextbox
33 = !
101 = e
10 you know, linefeed
So you don't have a vbCrLf at the end, you have a Lf :-)
Hope that helps you a little
Edit: Whoops...just made sure of that, and code *was* wrong
vb Code:
debug.print asc(right(.text,1)), asc(mid(.text,len(.text)-1,1))
Re: blank line at end in richtextbox
Quote:
Originally Posted by smUX
33 = !
101 = e
10 you know, linefeed
So you don't have a vbCrLf at the end, you have a Lf :-)
Hope that helps you a little
Edit: Whoops...just made sure of that, and code *was* wrong
vb Code:
debug.print asc(right(.text,1)), asc(mid(.text,len(.text)-1,1))
I think i am in business i was coding against .selrtf rather than .text
Thanks a lot