Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each line As String In TextBox1.Text.Split(vbNewLine)
TextBox2.Text &= GetTranslate(line) & vbNewLine
Next
TextBox2.Text = TextBox2.Text.Trim
End Sub
Function GetTranslate(ByVal word As String) As String
Try
Using adp As New OleDb.OleDbDataAdapter(Nothing, connectionString)
Using tbl As New DataTable
adp.SelectCommand.CommandText = "SELECT [Arabic] FROM [Subtitles] WHERE [English]=@English"
adp.SelectCommand.Parameters.AddWithValue("@English", word.Trim)
If adp.Fill(tbl) > 0 Then Return tbl.Rows(0).Item("Arabic")
adp.SelectCommand.CommandText = "SELECT [English] FROM [Subtitles] WHERE [Arabic]=@Arabic"
adp.SelectCommand.Parameters.AddWithValue("@Arabic", word.Trim)
If adp.Fill(tbl) > 0 Then Return tbl.Rows(0).Item("English")
Return word.Trim
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
For Each line As String In TextBox1.Text.Split(vbNewLine)
TextBox2.Text &= GetTranslate(line) & vbNewLine
Next
TextBox2.Text = TextBox2.Text.Trim
End Sub
Function GetTranslate(ByVal word As String) As String
Try
Using adp As New OleDb.OleDbDataAdapter(Nothing, connectionString)
Using tbl As New DataTable
adp.SelectCommand.CommandText = "SELECT [Arabic] FROM [Subtitles] WHERE [English]=@English"
adp.SelectCommand.Parameters.AddWithValue("@English", word.Trim)
If adp.Fill(tbl) > 0 Then Return tbl.Rows(0).Item("Arabic")
adp.SelectCommand.CommandText = "SELECT [English] FROM [Subtitles] WHERE [Arabic]=@Arabic"
adp.SelectCommand.Parameters.AddWithValue("@Arabic", word.Trim)
If adp.Fill(tbl) > 0 Then Return tbl.Rows(0).Item("English")
Return word.Trim
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
