write a windows application that allows the user to enter
a seven-digit number in a multiple line textbox
when the user clicks the generate words button.

example 6392277 = NEWCARS

Partial Class Form1
    Inherits System.Windows.Forms.Form

    Public Numbers(7, 3) As String
    Public Phonenumber As Integer
    Public output As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        ' Dim Numbers(7, 3) As String

        Numbers(0, 0) = "A" '2
        Numbers(0, 1) = "B" '2    
        Numbers(0, 2) = "C" '2    
        Numbers(1, 0) = "D" '3    
        Numbers(1, 1) = "E" '3    
        Numbers(1, 2) = "F" '3    
        Numbers(2, 0) = "G" '4    
        Numbers(2, 1) = "H" '4   
        Numbers(2, 2) = "I" '4    
        Numbers(3, 0) = "J" '5    
        Numbers(3, 1) = "K" '5   
        Numbers(3, 2) = "L" '5    
        Numbers(4, 0) = "M" '6    
        Numbers(4, 1) = "N" '6    
        Numbers(4, 2) = "O" '6    
        Numbers(5, 0) = "P" '7    
        Numbers(5, 1) = "R" '7    
        Numbers(5, 2) = "S" '7    
        Numbers(6, 0) = "T" '8    
        Numbers(6, 1) = "U" '8    
        Numbers(6, 2) = "V" '8    
        Numbers(7, 0) = "W" '9    
        Numbers(7, 1) = "X" '9    
        Numbers(7, 2) = "Y" '9


    End Sub
    Private Sub GenerateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateButton.Click


        Dim phoneNumber As String = GetNumber()

        'check if the number contains 0 or 1
        While phoneNumber.Contains("0") Or phoneNumber.Contains("1")
            phoneNumber = GetNumber()
        End While

        'create a hashtable to hold the digits
        Dim arrayL As New Hashtable
        Dim x As Integer = 1
        For i As Integer = 65 To 90 Step 3
            arrayL.Add(x, New Char() {Chr(i), Chr(i + 1), Chr(i + 2)})
            x += 1
        Next

        Dim word As String = ""

        'creates only 3 words out of the phonenumber
        For i As Integer = 0 To 2

            For Each s As String In phoneNumber
                word = word & DirectCast(arrayL.Item(CInt(s)), Char())(i).ToString
            Next
        Next

        output = PhoneNumberWordsListBox.Text


    End Sub

    

    Private Sub PhoneNumberTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhoneNumberTextBox.TextChanged
        Phonenumber = PhoneNumberTextBox.Text

    End Sub
    Private Function GetNumber() As String

        Return PhoneNumberTextBox.Text()
    End Function
End Class

Thanks you

Comments
duplicate posts

you never assign "output"
output = PhoneNumberWordsListBox.Text in your code means Nothing = nothing

try this:

For i As Integer = 0 To 2
                Dim word As String = ""
                For Each s As String In phoneNumber
                    word = word & DirectCast(arrayL.Item(CInt(s)), Char())(i).ToString
                Next
                PhoneNumberWordsListBox.AppendText(word & vbNewLine)
            Next
This article has been dead for over six months. Start a new discussion instead.