i am trying to developed a translator.the program request an english sentence as input and translate it into my local language(Twi).
i have the entire program written .
i am getting an error that is driving me crazy.
any help will be greatly appreciated .
vb is telling me that value of type 1-dimensional array of string cannot be converted string.
in the english=Getwords(inline)
this is the code have written

//thi subroutine translate english into twi

 Private Sub translateButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles translateButton1.Click

        Dim inline() As String
        Dim english As String
        Dim sentence As Translator
//get english words
        Dim line As String = englishTextBox1.Text.Trim.ToUpper
        If line.Substring(line.Length - 1) <> "." Then
            line &= "."
            inline = line.Replace(".", "").Split(" ")
        End If
        english = Getwords(inline)
        sentence = Translate(english)
        germanTextBox2.Text = sentence.twi.Trim & "."
    End Sub

//This fucntion gets the words one by one from the textbox

    Function Getwords(ByVal sentence As String) As String()
        Dim words(100) As String
        Dim length As Integer = 0
        Dim wordcount As Integer = 0
        Dim position As Integer = 0
        Do While position < sentence.Length - 1
            Do While ((sentence.Substring(position, 1) < "A") Or (sentence.Substring(position, 1) > "Z")) And (position < sentence.Length - 1)
                position += 1
            If position < sentence.Length - 1 Then
                length = 1
                Do While ((sentence.Substring(position + length, 1) >= "A") And (sentence.Substring(position + length, 1) <= "Z"))
                    length += 1
                wordcount += 1
                words(wordcount) = sentence.Substring(position, length)
                position += length
            End If
        ReDim Preserve words(wordcount)
        Return words
    End Function

The function GetWors is expected to return one or more words, but the receptor english is a string that can only hold one, so the conversion is not possible.

Changing to

Dim english() As String

will do the work.

Hope this helps

This article has been dead for over six months. Start a new discussion instead.