Avatar of isnoend2001
isnoend2001Flag for United States of America

asked on 

Proper way to check the length of data entered into a Richtextbox vb6

If Len(rtfTask.Text) < 4 Then
 or should it be
If Len(rtfTask.Textrtf) < 4 Then
which should be used ?
Visual Basic Classic

Avatar of undefined
Last Comment
Martin Liss
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of isnoend2001
isnoend2001
Flag of United States of America image

ASKER

Thanks
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Martin, I am interested in understanding the reason, can you please explain, for my knowledge?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Let's say you have a RTB called txtEdit and you put this code in a command button.
Private Sub Command1_Click()
Debug.Print txtEdit.Text
Debug.Print Len(txtEdit.Text)
Debug.Print
Debug.Print txtEdit.TextRTF
Debug.Print Len(txtEdit.TextRTF)
End Sub

Open in new window

If you then typed "This is a test" into the RTB you'd see this in the Immediate Window.
This is a test
 14

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 This is a test
\par }

 140
As you can see there's quite a difference because the TextRTF contains all the hidden formatting code.
Avatar of Karrtik Iyer
Karrtik Iyer
Flag of India image

Thanks Martin for the nice explanation.
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.

Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo