Gud Day Guys!

Re: MY thread Word Marquee or running text in text box, I got the working code. If you don't mind guys can you explain it me or simulate how this code work and what it means the mentioned variable? What 'Len' means? Thank you very much!

br.

here's the code:

dim str as string
dim i as integer

Private Sub Form_Load()
str = Text1.Text
i = 0
End Sub

Private Sub Timer1_Timer()
Timer1.Interval = 100
i = i + 1
Text1.Text = Left(str, i)
If i = Len(str) Then
i = 1
Timer1.Interval = 100
End If
End Sub

dim str as string
dim i as integer

'str', and 'i' are declared variables which can hold any values in accordance with their declared datatypes

Private Sub Form_Load()
str = Text1.Text
i = 0
End Sub

This code was written under the Form_load event so it means that:
the variable, 'str' should be assigned the value of whatever is in text1(which is a textbox on your form) and
the varable, 'i' is assigned the integer value of zero (0)

Private Sub Timer1_Timer()
Timer1.Interval = 100
i = i + 1
Text1.Text = Left(str, i)
If i = Len(str) Then
i = 1
Timer1.Interval = 100
End If
End Sub

This was to control how the timer control on your form should work and i would explain each line.
line 1....it has assigned the interval for the timer to hundred(The value is specified in milliseconds (1000 milliseconds = 1 second).
line 2.... The varaible 'i' with intial value zero incrememnts by one
line 3....this tells the compiler to begin from the first letter from the left of the value of the variable, 'str'. You need to remember here that the value of variable, 'str' is same as value of the textbox known as text1.
line 4......means that if the variable, 'i' which incrememnts by one equals to the number of characters in the textbox called text1 then the timer interval should be 100.

What 'Len' means

'len' means length

Edited 5 Years Ago by Netcode: n/a

This article has been dead for over six months. Start a new discussion instead.