منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : التعديد على الكود
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
اهلا بكم

كود البحث في ملف 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


اتمنى المساعده لتكون عملية البحث سريعه وبارك الله فيكم
طيب جرب هذه الطريقة
PHP كود :
Label7.Text ""

Dim lines As String() = IO.File.ReadAllLines("C:\ww.txt")

Dim contain As Boolean lines.Contains(TextBox1.TextStringComparer.OrdinalIgnoreCase)
If 
contain Then Label7.Text TextBox1.Text 
(22-04-16, 03:16 PM)derham كتب : [ -> ]طيب جرب هذه الطريقة
PHP كود :
Label7.Text ""

Dim lines As String() = IO.File.ReadAllLines("C:\ww.txt")

Dim contain As Boolean lines.Contains(TextBox1.TextStringComparer.OrdinalIgnoreCase)
If 
contain Then Label7.Text TextBox1.Text 

شكرا علي الرد


جربت الكود بس ما طلع النتيجه بعد البحث
مشكوررررررررررجداددداااااا

شكرااااااااااااااااااااااااااااااااا