السلام عليكم ورحمة الله وبركاته
لديا الكود التالي :
Dim MyString As String = FrmDoc.RichTextBox.Text
Dim Words() As String = MyString.Split(" "c)
Dim FiveWords() As String
Dim II As Integer
Dim FiveWordsOK() As String = {""}
For i = 0 To UBound(Words)
GSQLCmd.CommandType = CommandType.Text
GSQLCmd.CommandText = "Select* FROM FiveWords WHERE WordWithoutTashkeel LIKE '%" & Words(i) & "%'"
GDR = GSQLCmd.ExecuteReader
Do While GDR.Read()
'هنا نسند ناتج الاستعلام لمصفوفة الخمس كلمات
If GDR.GetSqlString(0).IsNull = False Then
'هنا يتم تقسم المصفوفة الخاصة بنتائج الاستعلام
FiveWords = Split(GDR.GetSqlString(0))
For II = 0 To UBound(FiveWords)
If Words(i) = txtto(FiveWords(II)) Then
' MsgBox("نعم الكلمة مطابقة")
MsgBox(FiveWords(II))
FiveWordsOK(i) = FiveWordsOK(i) + " " + FiveWords(II)
End If
Next II
End If
Application.DoEvents()
Loop
FrmDoc.RichTextBox.SelectionStart = FrmDoc.RichTextBox.Find(Words(i))
FrmDoc.RichTextBox.SelectedText = FiveWordsOK(i)
GDR.Close()
' Erase FiveWords
' Erase FiveWordsOK
Next iوهذه هي الدالة التى تقوم بمقارنة الكلمة من Rchtextbox مع الكلمات من المصفوفة الحاملة لناتج الاستعلام :
Public Function txtto(ByVal txt As String)
Dim str As String = txt
Dim ss As String = Nothing
For i As Integer = 0 To str.Length - 1
If Char.GetUnicodeCategory(str.Chars(i)) = UnicodeCategory.OtherLetter Or Char.GetUnicodeCategory(str.Chars(i)) = UnicodeCategory.SpaceSeparator Then
ss += str.Chars(i)
End If
Next
Return ss
End Functionورسالة الخطأ هي Index was outside the bounds of the array.
وتظهر عند السطر التالي :
If Words(i) = txtto(FiveWords(II)) Then
الرجاء تصحيح الكود وبارك الله فيكم