label max length
Page 1 of 111 Replies - 246 Views - Last Post: 10 January 2013 - 01:05 PM
#1
label max length
Posted 10 January 2013 - 08:04 AM
Replies To: label max length
#2
Re: label max length
Posted 10 January 2013 - 08:15 AM
Assuming you are dynamically changing the label-text, then just count the number of characters before you change the text.
A label has a MaximumSize property, but this is not the same as a maximum-length of characters.
This post has been edited by andrewsw: 10 January 2013 - 08:22 AM
#3
Re: label max length
Posted 10 January 2013 - 08:21 AM
This post has been edited by artemix22: 10 January 2013 - 08:22 AM
#4
Re: label max length
Posted 10 January 2013 - 09:28 AM
So, my question to you becomes: Isn't that enough characters? The average person, reading in English as their native language can read about 300 words per minute. If you take an average of about 4.5 letters per word, that means the average person can process about 1350 characters per minute. There are 34,164,000 minutes in the life of a 65-year old person, so, if that person did nothing but read your scrolling message box, 24 hours a day every day from birth to death, they'd have time to process 46,121,400,000 characters before their untimely death from acute eyestrain. There are 11 digits in 46,121,400,000, so that means you have another 131,061 digits available in your label object to display the remainder of your text to the dessicated corpse of your end user. Remind me again why you need it to be unlimited?
#5
Re: label max length
Posted 10 January 2013 - 09:54 AM
in a form i add 1 RichTextBox, 1 Button, 1 Timer and 1 Label.
button code :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = RichTextBox1.Text
Timer1.Start()
End Sub
timer code :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Left -= 1
If Label1.Right < Me.Left Then
Label1.Left = Me.Right
End If
End Sub
run and try to add 6,857 character on RTB, label will not show text from RTB, but if you add 6,856 character it will show the text.
here is character counter to make it easy on counting : character counter
it's for government announcement bro, sure i need it no limit.
This post has been edited by artemix22: 10 January 2013 - 09:57 AM
#6
Re: label max length
Posted 10 January 2013 - 10:09 AM
artemix22, on 10 January 2013 - 09:54 AM, said:
in a form i add 1 RichTextBox, 1 Button, 1 Timer and 1 Label.
button code :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = RichTextBox1.Text
Timer1.Start()
End Sub
timer code :
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Left -= 1
If Label1.Right < Me.Left Then
Label1.Left = Me.Right
End If
End Sub
run and try to add 6,857 character on RTB, label will not show text from RTB, but if you add 6,856 character it will show the text.
here is character counter to make it easy on counting : character counter
it's for government announcement bro, sure i need it no limit.
Well isn't that interesting? You're correct that the label won't display over 6,856, but the .text value will hold way more characters than that, so it's not a problem with the limit to what it can hold, only a limit of what it can display.
The way I would fix this is to stop trying to display the entire message at once; instead, just read the RTB character by character and add each character to the end of the string displayed by your label until you hit however many characters the label can display, then drop the oldest character from the beginning of the string and add the next character to the end of the string until you've displayed the whole message, then loop back to the beginning and start it again.
Also, I didn't mean to say that the .text property maxes out at 131,072 characters above, I meant to say it maxes out at a number of characters with 131,072 zeros, for which I'm pretty sure no one has invented a word.
This post has been edited by C.Andrews: 10 January 2013 - 10:12 AM
#7
Re: label max length
Posted 10 January 2013 - 10:14 AM
#8
Re: label max length
Posted 10 January 2013 - 10:25 AM
andrewsw, on 10 January 2013 - 10:14 AM, said:
I thought about that too, but I threw in a refresh after the value changes each time to rule that out in my experimental code, so I don't think that's it. The label just refuses to display its value after a certain point, and loses its value completely after a later point.
#9
Re: label max length
Posted 10 January 2013 - 10:28 AM
Edited: Scrub this, it would probably stutter.
This post has been edited by andrewsw: 10 January 2013 - 10:29 AM
#10
Re: label max length
Posted 10 January 2013 - 10:33 AM
btw thanks for your reply guys, i appreciate it.
This post has been edited by artemix22: 10 January 2013 - 10:38 AM
#11
Re: label max length
Posted 10 January 2013 - 12:46 PM
Public Class Form1
Dim strToDisplay As String
Dim intStep As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If intStep > Len(TextBox1.Text) - 1 Then intStep = 0
strToDisplay = TextBox1.Text.Substring(intStep, 1)
Label1.Text = Label1.Text & strToDisplay
If Len(Label1.Text) > 50 Then Label1.Text = Label1.Text.Substring(1, 50)
Label1.Update()
intStep += 1
End Sub
End Class
While looking for a simple solution to make it animated better, I came across this thread. I tried to attach their solution to this message (in case the link goes dead), but I keep getting a non-specific server error when I try to attach it. Sorry
-C
#12
Re: label max length
Posted 10 January 2013 - 01:05 PM
|
|

New Topic/Question
Reply



MultiQuote




|