Hi,
I have a little problem with reading data from text file which has more than 5000 words. To make long story short, I need to make english to serbian translator.It has to have 2 text boxes,one for english word and one translation; one button for translating. I tried almost everything from this site but it works on a small number of lines, at 2000 and more computer frezzes. The biggest catch is that I have to read words from file into array and then i have to search the word... So if anyone could help me about this I would be really gratefull.
Thanks

Recommended Answers

All 3 Replies

I don't see the problem. Of course, you didn't show us your code. The following works fine for my test file of around 5600 lines of text.

Dim lines() As String = System.IO.File.ReadAllLines("D:\temp\Asimov, Isaac - Elija Baley 01 - The Caves of Steel.txt")

ill give it a try... and post what i have done :)

tnx it works xD
here is my code:

Public Class Form1
    Dim rec As String
    Dim broj_linija As Integer
    Dim pozicija_srpske_reci, pocetak_engleske_reci, kraj_engleske_reci As Integer
    Dim recnik(), engleska_rec 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\recnik3\recnik3a.txt") Then
            recnik = System.IO.File.ReadAllLines("C:\Users\Slobo\Desktop\recnik3\recnik3a.txt")
        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_srpske_reci = 0
        rec = TextBox1.Text
        broj_linija = recnik.Length
        For i = 0 To broj_linija - 1
            If InStr(recnik(i), rec) = 1 Then
                pozicija_srpske_reci = i
            End If
        Next
        If pozicija_srpske_reci = 0 Then
            MsgBox("Ne postoji trazena rec!")
        End If
        engleska_rec = recnik(pozicija_srpske_reci).ToString
        pocetak_engleske_reci = InStr(engleska_rec, " ") + 1
        kraj_engleske_reci = InStrRev(engleska_rec, " ")
        engleska_rec = Mid(engleska_rec, pocetak_engleske_reci, kraj_engleske_reci - pocetak_engleske_reci)
        MsgBox(engleska_rec)
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.