04-01-16, 05:37 AM
(آخر تعديل لهذه المشاركة : 04-01-16, 05:39 AM {2} بواسطة silverlight.)
هذا مثال لكيفية الإضافة و لتنفيذ الكود عليك ان تضيف الاتي الي الفورم
Button
TextBox
ListBox
ثم استخدم الكود التالي
لكن الافضل ان تستخدم Generic Dictinary بدلا من HashTable او تستخدم Generic HashSet لأن HashTable مثله مثل ArrayList فهو من الممكن ان يقبل بيانات من اي نوع لأن مدخلاته اصلا عبارة عن Object
Public Class Form1
Private hasher As Hashtable = New Hashtable
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String = TextBox1.Text
If Not (String.IsNullOrEmpty(s)) Then
Dim count As Integer = hasher.Count
Dim index As Integer = count + 1
If Not hasher.Contains(s) Then
hasher.Add(index, s)
End If
End If
ListBox1.Items.Clear()
For Each item In hasher.Values
ListBox1.Items.Add(item)
Next
TextBox1.Text = ""
End Sub
End Class
Button
TextBox
ListBox
ثم استخدم الكود التالي
لكن الافضل ان تستخدم Generic Dictinary بدلا من HashTable او تستخدم Generic HashSet لأن HashTable مثله مثل ArrayList فهو من الممكن ان يقبل بيانات من اي نوع لأن مدخلاته اصلا عبارة عن Object
Public Class Form1
Private hasher As Hashtable = New Hashtable
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim s As String = TextBox1.Text
If Not (String.IsNullOrEmpty(s)) Then
Dim count As Integer = hasher.Count
Dim index As Integer = count + 1
If Not hasher.Contains(s) Then
hasher.Add(index, s)
End If
End If
ListBox1.Items.Clear()
For Each item In hasher.Values
ListBox1.Items.Add(item)
Next
TextBox1.Text = ""
End Sub
End Class

