hi again :)
i have problem with finding cyrilic words in my txt file...words in txt file are arranged like this:
one један
two два
three три
etc...
before word "one" and after word "један" there is blank space...
so problem starts in button3_click... what ever i type in texbox3 result is the same,it wont work...actualy it cant find the word... here is whole code:
Public Class Form1
Dim rec As String
Dim broj_linija As Integer
Dim pozicija_srpske_reci, pozicija_engleske_reci,
pocetak_srpske_reci, kraj_srpske_reci,
pocetak_engleske_reci, kraj_engleske_reci As Integer
Dim recnik(), linija,
linija2, srpska_rec, engleska_rec As String
Dim putanja As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.FileSystem.FileExists("C:\Users\Slobo\Desktop\eng-srp recnik\ss.txt") Then
recnik = System.IO.File.ReadAllLines("C:\Users\Slobo\Desktop\eng-srp recnik\ss.txt", System.Text.Encoding.GetEncoding(1251))
Else
MsgBox("Ne postoji tekstualni dokument")
Close()
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Button2.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button2.Enabled = True
pozicija_engleske_reci = 0
rec = TextBox1.Text
broj_linija = recnik.Length
For i = 0 To broj_linija - 1
If InStr(recnik(i), rec) = 1 Then
pozicija_engleske_reci = i
End If
Next
If pozicija_engleske_reci = 0 Or TextBox1.TextLength = 0 Then
MsgBox("Ne postoji trazena rec!")
GoTo A
End If
linija = recnik(pozicija_engleske_reci).ToString
pocetak_srpske_reci = InStr(linija, " ") + 1
kraj_srpske_reci = InStrRev(linija, " ")
srpska_rec = Mid(linija, pocetak_srpske_reci, kraj_srpske_reci - pocetak_srpske_reci)
TextBox2.Text = srpska_rec
A:
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
putanja = "C:\Users\Slobo\Desktop\eng-srp recnik\izgovor\" + srpska_rec + ".wav"
My.Computer.Audio.Play(putanja)
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
Button4.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Button4.Enabled = True
pozicija_srpske_reci = 1
rec = TextBox3.Text.ToString
broj_linija = recnik.Length
For i = 0 To broj_linija - 1
If InStr(recnik(i), rec, CompareMethod.Text) = 1 Then
MsgBox("1")
pozicija_srpske_reci = i
End If
Next
If pozicija_srpske_reci = 1 Or TextBox3.TextLength = 0 Then
MsgBox("Ne postoji trazena rec!")
GoTo A
End If
linija2 = recnik(pozicija_engleske_reci).ToString
pocetak_engleske_reci = 1
kraj_engleske_reci = InStr(2, linija, " ")
engleska_rec = Mid(linija, pocetak_engleske_reci, kraj_engleske_reci - 1)
TextBox4.Text = engleska_rec
A:
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
putanja = "C:\Users\Slobo\Desktop\eng-srp recnik\izgovor\" + engleska_rec + ".wav"
My.Computer.Audio.Play(putanja)
End Sub
End Class