Hi again!
Why is it that when I try to draw multiple strings in a list, it only draws one? How can I make it so that it draws all the strings at once? There must be a problem with the For Each loop. Thanks for the help in advance!
vb Code:
Public Class Form1 'EACH RANDOMTEXT HAS 3 PROPERTIES: TEXT, LOCATIONX, AND LOCATIONY. 'I AM TRYING TO CREATE AN EFFECT TO SCATTER TEXT TO SLOWLY COVER THE SCREEN. Dim F As New Font("Arial", 16, FontStyle.Bold) Dim RandomTexts As New List(Of RandomText) Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint For Each RandomText In RandomTexts e.Graphics.DrawString(RandomText.Text, F, Brushes.Black, New Point(RandomText.LocationX, RandomText.LocationY)) Next End Sub Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick RandomTexts.Add(New RandomText("", New Point(0, 0))) 'MsgBox(RandomTexts.Count) End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick NewText() Me.Invalidate() End Sub Private Sub NewText() Dim R As New Random Dim Alphabet As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" Dim N As Int32 = CInt(R.Next(3, 15)) Dim A As Int32 = CInt(R.Next(Alphabet.Length)) For Each RandomText In RandomTexts RandomText.Text = "" RandomText.LocationX = R.Next(-10, 390) RandomText.LocationY = R.Next(-10, 390) Do Until N <= 0 N -= 1 RandomText.Text += Alphabet(A) A = CInt(R.Next(Alphabet.Length)) Loop Next End Sub End Class


Reply With Quote
