Mickey2000
Technical User
This program is to read the text files into three parallel arrays, sort them according to the english words, and when a sentence is typed in print out the translastions. The text file contains “oui, yes, die; table, table diesch” which are english, French, and german. I cannot seem to get any output. This is what I have so far, any help would be greatly appreciated. What do I need to add?
Private Sub Form_Load()
Dim i As Integer
Open "a:\TRANSLATION.TXT" For Input As #1
For i = 0 To 15
Input #1, eng(i), fr(i), ger(i)
Next i
Close #1
End Sub
Private Sub cmdTranslate_Click()
Call SortWords
Call GetInput
End Sub
Private Sub SortWords()
Dim passNum As Integer, index As Integer
'Use of Bubble Sort to organize the data
For passNum = 0 To 14
For index = 0 To 14 - passNum
If eng(index) > eng(index + 1) Then
Call SwapData(index)
End If
Next index
Next passNum
End Sub
Private Sub SwapData(index As Integer)
'Swap Words
Call SwapStr(eng(index), eng(index + 1))
Call SwapStr(fr(index), fr(index + 1))
Call SwapStr(ger(index), ger(index + 1))
End Sub
Private Sub SwapStr(a As String, b As String)
Dim temp As String
'Interchanges values of a & b
temp = a
a = b
b = temp
End Sub
Private Sub GetInput()
Dim temparray() As String
Dim i As Integer, result As Integer
temparray = Split(txtEnglish.Text, Chr(32))
For i = LBound(temparray) To UBound(temparray)
Call FindWord(temparray, result)
If result > 0 Then
Call ShowTranslation(result)
Else
MsgBox , "temparray& not in file", , "Error!"
End If
Next i
End Sub
Private Sub ShowTranslation(index As Integer)
'Displays words in french and german
picFrench.Print fr(index)
picGerman.Print ger(index)
End Sub
Private Sub FindWord(temparray() As String, result As Integer)
Dim first As Integer, middle As Integer, last As Integer
Dim foundFlag As Boolean
'Binary search table for words entered
first = 0
last = 15
foundFlag = False
Do While ((first <= last) / 2)
Select Case UCase(eng(middle))
Case temparray
foundFlag = True
Case Is > temparray
last = middle - 1
Case Is < temparray
first = middle + 1
End Select
Loop
If foundFlag Then
result = middle
Else
result = 0
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Open "a:\TRANSLATION.TXT" For Input As #1
For i = 0 To 15
Input #1, eng(i), fr(i), ger(i)
Next i
Close #1
End Sub
Private Sub cmdTranslate_Click()
Call SortWords
Call GetInput
End Sub
Private Sub SortWords()
Dim passNum As Integer, index As Integer
'Use of Bubble Sort to organize the data
For passNum = 0 To 14
For index = 0 To 14 - passNum
If eng(index) > eng(index + 1) Then
Call SwapData(index)
End If
Next index
Next passNum
End Sub
Private Sub SwapData(index As Integer)
'Swap Words
Call SwapStr(eng(index), eng(index + 1))
Call SwapStr(fr(index), fr(index + 1))
Call SwapStr(ger(index), ger(index + 1))
End Sub
Private Sub SwapStr(a As String, b As String)
Dim temp As String
'Interchanges values of a & b
temp = a
a = b
b = temp
End Sub
Private Sub GetInput()
Dim temparray() As String
Dim i As Integer, result As Integer
temparray = Split(txtEnglish.Text, Chr(32))
For i = LBound(temparray) To UBound(temparray)
Call FindWord(temparray, result)
If result > 0 Then
Call ShowTranslation(result)
Else
MsgBox , "temparray& not in file", , "Error!"
End If
Next i
End Sub
Private Sub ShowTranslation(index As Integer)
'Displays words in french and german
picFrench.Print fr(index)
picGerman.Print ger(index)
End Sub
Private Sub FindWord(temparray() As String, result As Integer)
Dim first As Integer, middle As Integer, last As Integer
Dim foundFlag As Boolean
'Binary search table for words entered
first = 0
last = 15
foundFlag = False
Do While ((first <= last) / 2)
Select Case UCase(eng(middle))
Case temparray
foundFlag = True
Case Is > temparray
last = middle - 1
Case Is < temparray
first = middle + 1
End Select
Loop
If foundFlag Then
result = middle
Else
result = 0
End If
End Sub