How to get a srolling text?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Hello, sorry my english isn't very good.
How to get a scrolling text (in a textbox or label), from down to high?
I have this code, it's scrolling from right to left, and "timscroll" = timer1
How to get a scrolling text (in a textbox or label), from down to high?
I have this code, it's scrolling from right to left, and "timscroll" = timer1
Code: Select all
btw; I use ms vb 2010Private Sub timscroll_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timscroll.Tick
If Label1.Left = 0 - Label1.Width Then
Label1.Left = Me.Width
Label1.Left = Label1.Left - 1
Else
Label1.Left = Label1.Left - 1
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Left = Me.Width
End Sub
Scrolling text from bottom to top?
Try this:
Try this:
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim starting As String = "starting value "
Dim out As String = ""
For i As Integer = 0 To starting.Length - 1
out += starting(i) & vbLf
Next
Label1.Text = out
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
Label1.Text = Label1.Text.Insert(Label1.Text.Length, Label1.Text.Substring(0, 2))
Label1.Text = Label1.Text.Remove(0, 2)
Timer1.Start()
End Sub
it works, but that is not exactly what I mean:
Now it scrolls char for char to down, lile this:
t
e
x
t
h
e
r
e
But I would like this:
text here
The scroll-position must be scrolling over the whole form
Now it scrolls char for char to down, lile this:
t
e
x
t
h
e
r
e
But I would like this:
text here
The scroll-position must be scrolling over the whole form
Scroll position? For right to left scrolling you don't need to use the Form1_Load part, just change the count parameter in substring/remove to 1 and start the timer.
I think it's better to show you an example, so download this little example program, and push the about button, to see what I mean 
http://www.mediafire.com/?e19v9g32axmmi10

http://www.mediafire.com/?e19v9g32axmmi10
I have no idea how it's called, but I would it exactly as the example 

Oh if the label itself has to scroll instead of the text try:
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Top -= 1
If Label1.Top < 0 Then ' label won't go above the top of the form
Label1.Top = 10 'this is the original height
End If
End Sub
Yes, It works!
But if the text is for the first time at the top, it will stay there.
Now I want, if the text for the first time at top, the text disappears and show again from bottom (like in the example) and repeat that for x times
But if the text is for the first time at the top, it will stay there.
Now I want, if the text for the first time at top, the text disappears and show again from bottom (like in the example) and repeat that for x times
This should work:
Code: Select all
If you want a fade effect you will have to change the label's Paint event or use a graphics object on an image to draw strings. Dim times As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
For i As Integer = 0 To Me.Controls.Count - 1
If TypeOf Me.Controls(i) Is Label Then
Me.Controls(i).Top -= 1
If Me.Controls(i).Top < 0 Then
Me.Controls(i).Top = 40
End If
End If
Next
times += 1
If times < x Then
Timer1.Start()
End If
End Sub
Copyright Information
Copyright © Codenstuff.com 2020 - 2023