On a phone keypad, each of the digits 2 through 9 has a segment of the alphabet associated with it. How does one write a program that displays the associated numeric digit given an alphabetic character.

Recommended Answers

All 2 Replies

You could use a dictionary

Dim chardic As Dictionary(Of Char, Integer)
Dim input As Char = "B"c
Dim output As Integer = chardic(input)

What about select case statement?

Select Case charinput
    Case 'A' To 'C' digit = 1
    Case 'D','E','F' digit = 2 'etc

End Select
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.