Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Characters count

Status
Not open for further replies.
Oct 28, 2003
50
0
0
MY
Hi...

i'm using Len function to count the number of characters that the user has entered in several textboxes:

totalChar=len(text(1).text) + len(text(2).text)+len(text(3).text)

me.txtShowTotal=totalChar

The problem that i encountered is when the user key in the 1st letter the counting did'nt starts from 1 but it starts from 31....i have no idea why this is happening...

can somebody help me...
 
I don't know. It works for me.

You have an array of text boxes. Three. Plus another text box which shows the total number of characters in the text box array.
Were the text boxes empty to begin with? Are they multiline and is it possible the text is being typed on the second line and not the first?
Put your code in the Text Change event and monitor it to see what happens. Maybe you'll pick up on something.



Code:
Private Sub Text1_Change(Index As Integer)
Dim totalChar%
totalChar = Len(Text1(0)) + Len(Text1(1)) _
+ Len(Text1(2))
Me.txtShowTotal = totalChar
End Sub

 
Hello mosaic1,

i've tried to put the code in the on_change event but the same problem exist...

for your information, my array starts from text(2) until text(9).... text(0) and text(1) did not exist....this is done by the former programmer who developed this system which i'm am now handling....i definitely cannot simply change the textbox name because it will effect many other major functions...... I have tried doing this on a new textboxes where the array starts from 0 and it works fine...

I'm not sure why when the array does not starts from 0, the counting becomes haywire..........
the concept is still the same...isn't it...?
 
cenderawasih,

Hi. Yes it is and again, it works for me.
I started at text1(2) and the count was fine.

Text1(0) and Text1(1) do not exist or are hidden? If they don't exist, I can't think of what may be doing this other than having invisible characters in a text box. Starting on the second line instead of the first. . Maybe someone else will come along with some answers.

Good luck on this. It sounds frustrating.

 
Thanks mosaic1...

i really appreciate yor help....my problem is now solved... the textboxes has a default value that makes the counting does not starts from 1....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top