Public Class Form1
Private txt As String = "vb4arab#data#ali#color#sunclock#ali#anystring#---------"
Public lastTxt As Integer = -1
Private txtLock As New Object
Private strings() As String = New String(100) {}
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
' و ممكن تكتب الكود بين هاتين السطرين
SyncLock txtLock
For Each s As String In txt.Split("#"c)
lastTxt += 1
If lastTxt < txt.Length Then
strings(lastTxt) = s
End If
Next
End SyncLock
For i = 0 To strings.Length - 1
Dim current As String = strings(i)
If Not String.IsNullOrEmpty(current) Then
ListBox1.Items.Add(current)
End If
Next
'' أو ممكن تستخدم التايمر نفسه
'SyncLock Timer1
' For Each s As String In txt.Split("#"c)
' lastTxt += 1
' If lastTxt < txt.Length Then
' strings(lastTxt) = s
' End If
' Next
'End SyncLock
'For i = 0 To strings.Length - 1
' Dim current As String = strings(i)
' If Not String.IsNullOrEmpty(current) Then
' ListBox1.Items.Add(current)
' End If
'Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
End Class