|
Tipp 0051
|
Laufschrift
|
|
|
Autor/Einsender: Datum: |
|
Michael Werner 01.08.2004 |
|
Entwicklungsumgebung: |
|
VB.Net 2003 |
Framework: |
|
1.1 |
|
|
Dieser Tipp zeigt, wie man mit ganz einfachen Mitteln über die Methode String.Substring()
und einem Timer eine Laufschrift erzeugen kann.
|
|
|
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private Changed As Boolean
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Start [ENTER]" Then
Start()
Else
Stopp()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer1.Tick
Dim s As String = TextBox1.Text
Static i As Integer
If Changed Then
i = 0
Changed = False
End If
If i = s.Length Then
i = 0
Label1.Text = ""
End If
Label1.Text = Label1.Text & s.Substring(i, 1)
i += 1
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Eine Laufschrift erzeugen." & vbNewLine & _
"Ein Tipp von vb-fun.de." & vbNewLine & _
"Ganz einfach in einem Timer-Tick-Event:" & vbNewLine & _
"Label1.Text = Label1.Text + Textbox1.Text.Substring(i, 1)"
TextBox1.SelectionLength = 0
End Sub
Private Sub Start()
Timer1.Enabled = True
Timer1.Interval = 100
Button1.Text = "Stop [ENTER]"
End Sub
Private Sub Stopp()
Timer1.Enabled = False
Button1.Text = "Start [ENTER]"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles TextBox1.TextChanged
Changed = True
Stopp()
Label1.Text = String.Empty
End Sub
End Class
|
|
|
|
|
Windows-Version |
98/SE |
|
|
ME |
|
|
NT |
|
|
2000 |
|
|
XP |
|
|
Vista |
|
|
Win
7 |
|
|
|
|
Download (6,4 kB)
|
Downloads bisher: [ 1373 ]
|
|
|