21-04-16, 03:05 PM
اهلا بكم
كود البحث في ملف txt
الكود شغال تمام بس في عملية البحث يكون بطي جدا
ملف ال txt يتون من 1000 سطر
مثال
وهذا الكود
اي عبارة تنكتتب في TextBox1.Text
يتم البحث عنها والنتيجه تكون Label7.Text
اتمنى المساعده لتكون عملية البحث سريعه وبارك الله فيكم
كود البحث في ملف txt
الكود شغال تمام بس في عملية البحث يكون بطي جدا
ملف ال txt يتون من 1000 سطر
مثال
كود :
108FB010
10AD2814
12AT096
12AT111
13AT162
13DNI400
13HS1696
13RF202
وهذا الكود
كود :
'read info from the file'
Dim objReader As New System.IO.StreamReader("C:\ww.txt")
Dim strTextFileInfo() As String 'an array of strings for each line'
Dim arrCounter As Integer = 0 'counter for the array'
Dim strTextToSearch As String = String.Empty 'text to saerch'
'read all lines'
Do While objReader.Peek <> -1
'redim the array with the needet elements'
ReDim Preserve strTextFileInfo(arrCounter)
'input the info'
strTextFileInfo(arrCounter) = objReader.ReadLine
'increase the elements'
arrCounter = arrCounter + 1
Loop
'enter the text to search'
strTextToSearch = TextBox1.Text
'search all elements for the string'
For i As Integer = 0 To arrCounter - 1
If strTextFileInfo(i).ToLower.Contains(strTextToSearch.ToLower) Then
'display the found elements'
Label7.Text = strTextFileInfo(i)
End If
Next
اي عبارة تنكتتب في TextBox1.Text
يتم البحث عنها والنتيجه تكون Label7.Text
اتمنى المساعده لتكون عملية البحث سريعه وبارك الله فيكم