So basically my teacher wants us to make a program that takes user input such as 1 and makes it into "one"
My problem with this lies in once I get into the 10s, 100s, and 1000s I'm not sure how to go about taking the input and assigning each number a word. I'm not allowed to use arrays and such only case, if..then and string search type functions.
So far this is what I have
Option Strict On Public Class Form1 Dim num0 As String = "Zero" Dim num1 As String = "One" Dim num2 As String = "Two" Dim num3 As String = "Three" Dim num4 As String = "Four" Dim num5 As String = "Five" Dim num6 As String = "Six" Dim num7 As String = "Seven" Dim num8 As String = "Eight" Dim num9 As String = "Nine" Dim num10 As String = "Ten" Dim num11 As String = "Eleven" Dim num12 As String = "Twelve" Dim num13 As String = "Thirteen" Dim num14 As String = "Fourteen" Dim num15 As String = "Fifteen" Dim num16 As String = "Sixteen" Dim num17 As String = "Seventeen" Dim num18 As String = "Eightteen" Dim num19 As String = "Nineteen" Dim num20 As String = "Twenty" Dim num30 As String = "Thirty" Dim num40 As String = "Fourty" Dim num50 As String = "Fifty" Dim num60 As String = "Sixty" Dim num70 As String = "Seventy" Dim num80 As String = "Eighty" Dim num90 As String = "Ninety" Dim numsd As String = "" Dim num100 As String = "Hundred" Dim num1000 As String = "Thousand" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim firstAndlastName As String = InputBox("Please enter first and last name:", "Enter Name:", "John Doe") lblfnameoutput.Text = firstAndlastName.Substring(0, firstAndlastName.IndexOf(" ")) lbllnameoutput.Text = firstAndlastName.Substring(firstAndlastName.IndexOf(" ") + 1) lbldtimeoutput.Text = CStr(Date.Today()) End Sub Private Sub btnenglishconv_Click(sender As Object, e As EventArgs) Handles btnenglishconv.Click Dim usernumber As Integer = CInt(txtboxnumbinput.Text) If usernumber < 0 Then MessageBox.Show("Number must be greater than 0") ElseIf usernumber > 3999 Then MessageBox.Show("Number must be less than 4000") End If If usernumber = 0 Then lbld.Text = num0 ElseIf usernumber <= 20 Then Select Case usernumber Case 1 lbld.Text = num1 Case 2 lbld.Text = num2 Case 3 lbld.Text = num3 Case 4 lbld.Text = num4 Case 5 lbld.Text = num5 Case 6 lbld.Text = num6 Case 7 lbld.Text = num7 Case 8 lbld.Text = num8 Case 9 lbld.Text = num9 Case 10 lbld.Text = num10 Case 11 lbld.Text = num11 Case 12 lbld.Text = num12 Case 13 lbld.Text = num13 Case 14 lbld.Text = num14 Case 15 lbld.Text = num15 Case 16 lbld.Text = num16 Case 17 lbld.Text = num17 Case 18 lbld.Text = num18 Case 19 lbld.Text = num19 Case 20 lbld.Text = num20 End Select End If End Sub End Class
I'm curious whether a const would be better to store the variables in or if each number should have its own?
Also if I do a const and do an index to find different numbers and match then up would that be an easier solution?
My main problem is not knowing how to take the usernumber dividing it by a 10,100, or 1000 and getting the number needed from it for each place value. I apologize if I do not come across as clear, but I've been spending hours on something which seems easy, but to me is not.