|
-
May 22nd, 2007, 11:59 AM
#1
Thread Starter
PowerPoster
[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 ?
.
-
May 22nd, 2007, 12:11 PM
#2
PowerPoster
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
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
May 22nd, 2007, 12:33 PM
#3
Thread Starter
PowerPoster
Re: blank line at end in richtextbox
 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
-
May 22nd, 2007, 01:04 PM
#4
PowerPoster
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)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
May 22nd, 2007, 01:56 PM
#5
Thread Starter
PowerPoster
Re: blank line at end in richtextbox
 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
-
May 22nd, 2007, 02:03 PM
#6
PowerPoster
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
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
May 22nd, 2007, 02:14 PM
#7
Thread Starter
PowerPoster
Re: blank line at end in richtextbox
 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
-
May 22nd, 2007, 02:20 PM
#8
PowerPoster
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))
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
May 22nd, 2007, 02:28 PM
#9
Thread Starter
PowerPoster
Re: blank line at end in richtextbox
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|