29-04-15, 08:02 PM
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MovieDic1.0.0.0.0.accdb"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = ReplaceTranslate(TextBox1.Text)
End Sub
Function ReplaceTranslate(ByVal content As String) As String
Try
Dim count As Integer = 0
Using adp As New OleDbDataAdapter("SELECT * FROM [Subtitles]", connectionString)
Using tbl As New DataTable
If adp.Fill(tbl) > 0 Then
For Each row As DataRow In tbl.Rows
Dim en As String = row.Item("English").Replace("?", "\?")
Dim ar As String = row.Item("Arabic")
count += Regex.Matches(content, en, RegexOptions.IgnoreCase).Count
content = Regex.Replace(content, en, ar, RegexOptions.IgnoreCase)
Next
End If
End Using
End Using
MsgBox(IIf(count = 0, "لم يتم العثور على الكلمات", "تم العثور على (" & count & ") من الكلمات"))
Return content
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = ReplaceTranslate(TextBox1.Text)
End Sub
Function ReplaceTranslate(ByVal content As String) As String
Try
Dim count As Integer = 0
Using adp As New OleDbDataAdapter("SELECT * FROM [Subtitles]", connectionString)
Using tbl As New DataTable
If adp.Fill(tbl) > 0 Then
For Each row As DataRow In tbl.Rows
Dim en As String = row.Item("English").Replace("?", "\?")
Dim ar As String = row.Item("Arabic")
count += Regex.Matches(content, en, RegexOptions.IgnoreCase).Count
content = Regex.Replace(content, en, ar, RegexOptions.IgnoreCase)
Next
End If
End Using
End Using
MsgBox(IIf(count = 0, "لم يتم العثور على الكلمات", "تم العثور على (" & count & ") من الكلمات"))
Return content
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
