Option Explicit
Global Eword As String
Global Initial(1, 100) As String
Global Vowel(1, 100) As String
Global Final(1, 100) As String
Global Vocab(1, 2000) As String
Global Initial_end, Vowel_end, Final_end, Vocab_end As Integer
Private Sub readEnglish()
Dim k As Integer
Initial_end = DataEnd(2)
Vowel_end = DataEnd(5)
Final_end = DataEnd(8)
Vocab_end = DataEnd(11)
For k = 4 To Vocab_end
UserForm1.ComboBox1.AddItem Cells(k, 11).Value
Next k
UserForm1.Show
End Sub
Sub Main()
Dim i, itemSelect As Integer
Eword = Excel.WorksheetFunction.Proper(UserForm1.ComboBox1.Value)
'--------------- Get value
For i = 3 To Initial_end 'Initial
Initial(0, i) = Sheets(2).Cells(i, 1).Value 'eng
Initial(1, i) = Sheets(2).Cells(i, 2).Value 'thai
Next i
For i = 3 To Vowel_end 'vowel
Vowel(0, i) = Sheets(2).Cells(i, 4).Value 'eng
Vowel(1, i) = Sheets(2).Cells(i, 5).Value 'thai
Next i
For i = 3 To Final_end 'final
Final(0, i) = Sheets(2).Cells(i, 7).Value 'eng
Final(1, i) = Sheets(2).Cells(i, 8).Value 'thai
Next i
For i = 3 To Vocab_end 'final
Vocab(0, i) = Sheets(2).Cells(i, 11).Value
Vocab(1, i) = Sheets(2).Cells(i, 12).Value
Next i
'---------------search in Eword
For i = 3 To Vocab_end
If Eword = Vocab(0, i) Then
UserForm1.Label8.Caption = Vocab(1, i)
Exit For
End If
Next i
For i = 3 To 27
If InStr(1, Eword, Vowel(0, i)) Then
If Len(Vowel(0, i)) = 1 Then
ElseIf Len(Vowel(0, i)) = 2 Then
Else
End If
UserForm1.Label1.Caption = Left(Eword, Findposition(Eword, Vowel(0, i)))
UserForm1.Label2.Caption = Vowel(0, i)
UserForm1.Label3.Caption = Right(Eword, Len(Eword) - Len(Vowel(0, i)) - Findposition(Eword, Vowel(0, i)))
Exit For
End If
Next i
'------- Thai
For i = 3 To Initial_end
If UserForm1.Label1.Caption = Excel.WorksheetFunction.Proper(Initial(0, i)) Then
UserForm1.Label4.Caption = Initial(1, i)
Exit For
Else
UserForm1.Label4.Caption = ".."
End If
Next i
For i = 3 To Vowel_end
If UserForm1.Label2.Caption = Vowel(0, i) Then
UserForm1.Label5.Caption = Vowel(1, i)
Exit For
Else
UserForm1.Label5.Caption = ".."
End If
Next i
For i = 3 To Final_end
If UserForm1.Label3.Caption = Final(0, i) Then
UserForm1.Label6.Caption = Final(1, i)
Exit For
Else
UserForm1.Label6.Caption = ".."
End If
Next i
Sheets(1).Select
End Sub
Function DataEnd(columnData As Integer) As Integer
Dim i As Integer
i = 3
Sheets(2).Select
Cells(4, columnData).Select
Do
Selection.Offset(1, 0).Select
i = i + 1
Loop Until ActiveCell.Value = ""
DataEnd = i
End Function
Sub test()
MsgBox Findposition("Threech", "ee")
End Sub
Function Findposition(Eword As String, ch As String) As Integer
Dim i As Integer
For i = 1 To Len(Eword)
If Mid(Eword, i, 1) = Left(ch, 1) Then
Findposition = i - 1
Exit For
End If
Next i
End Function
'
'
'
'
'
'
'