none
Help with this RRS feed

  • Question

  • Select Case input >= 10000 And input <= 99999
                Case True
                    one = input \ 1000 Mod 10
                    tenthousands = input \ 10000
                    hundreds = input \ 100 Mod 10
                    tens = input \ 10 Mod 10
                    ones = input Mod 10000 Mod 10
                    teens = input Mod 100
                    firstteens = input \ 1000
     
                    Select Case tenthousands
    
                        Case 1
                            outTenthousands = "Ten"
                        Case 2
                            outTenthousands = "Twenty"
                        Case 3
                            outTenthousands = "Thirty"
                        Case 4
                            outTenthousands = "Fourty"
                        Case 5
                            outTenthousands = "Fifty"
                        Case 6
                            outTenthousands = "Sixty"
                        Case 7
                            outTenthousands = "Seventy"
                        Case 8
                            outTenthousands = "Eighty"
                        Case 9
                            outTenthousands = "Ninety"
                    End Select
                    Select Case ones
                        Case 1
                            outOnes = "One"
                        Case 2
                            outOnes = "Two"
                        Case 3
                            outOnes = "Three"
                        Case 4
                            outOnes = "Four"
                        Case 5
                            outOnes = "Five"
                        Case 6
                            outOnes = "Six"
                        Case 7
                            outOnes = "Seven"
                        Case 8
                            outOnes = "Eight"
                        Case 9
                            outOnes = "Nine"
                    End Select
                    Select Case teens
                        Case 11
                            outOnes = "Eleven"
                        Case 12
                            outOnes = "Twelve"
                        Case 13
                            outOnes = "Thirteen"
                        Case 14
                            outOnes = "Fourteen"
                        Case 15
                            outOnes = "Fifteen"
                        Case 16
                            outOnes = "Sixteen"
                        Case 17
                            outOnes = "Seventeen"
                        Case 18
                            outOnes = "Eightteen"
                        Case 19
                            outOnes = "Nineteen"
                    End Select
                    Select Case hundreds
    
                        Case 1
                            outHundreds = "One hundred"
                        Case 2
                            outHundreds = "Two hundred"
                        Case 3
                            outHundreds = "Three hundred"
                        Case 4
                            outHundreds = "Four hundred"
                        Case 5
                            outHundreds = "Five hundred"
                        Case 6
                            outHundreds = "Six hundred"
                        Case 7
                            outHundreds = "Seven hundred"
                        Case 8
                            outHundreds = "Eight hundred"
                        Case 9
                            outHundreds = "Nine hundred"
                    End Select
                    Select Case tens
                        Case 2
                            outTens = "Twenty"
                        Case 3
                            outTens = "Thirty"
                        Case 4
                            outTens = "Fourty"
                        Case 5
                            outTens = "Fifty"
                        Case 6
                            outTens = "Sixty"
                        Case 7
                            outTens = "Seventy"
                        Case 8
                            outTens = "Eighty"
                        Case 9
                            outTens = "Ninety"
                    End Select
                    Select Case one
                        Case 1
                            outOne = "One"
                        Case 2
                            outOne = "Two"
                        Case 3
                            outOne = "Three"
                        Case 4
                            outOne = "Four"
                        Case 5
                            outOne = "Five"
                        Case 6
                            outOne = "Six"
                        Case 7
                            outOne = "Seven"
                        Case 8
                            outOne = "Eight"
                        Case 9
                            outOne = "Nine"
    
                    End Select
                    Select Case firstteens
                        Case 11
                            outOne = "Eleven"
                        Case 12
                            outOne = "Twelve"
                        Case 13
                            outOne = "Thirteen"
                        Case 14
                            outOne = "Fourteen"
                        Case 15
                            outOne = "Fifteen"
                        Case 16
                            outOne = "Sixteen"
                        Case 17
                            outOne = "Seventeen"
                        Case 18
                            outOne = "Eightteen"
                        Case 19
                            outOne = "Nineteen"
                        Case 20
                            outOne = "Twenty"
                    End Select
                    Select Case actualInput > 0
                        Case True
                            lblOutput.Text = outTenthousands & " " & outOne & " Thousand " & outHundreds & " " & outTens & " " & outOnes
                        Case False
                            lblOutput.Text = "Negative " & outTenthousands & " " & outOne & " Thousand " & outHundreds & " " & outTens & " " & outOnes
                    End Select
            End Select

    If i input 15,014 it outputs "Ten fifteen thousand fourteen" 

    Friday, August 11, 2017 9:55 AM

All replies

  • Your first select case does not make sense. How many tenthousands are there in 15,000? One? Then do you write one tenthousand five thousand or fifteen thousand?

    What will you write for 20,000? Two tenthousands? Or Twenty thousand? Seems you dont need the first select case for tenthousands since you dont use them in the wording.

    What if its 111,000? How will you write that? one onehundred thousand, one tenthousand, one thousand?

    Friday, August 11, 2017 11:43 AM
  • rei,

    I think this is what you're trying to accomplish?

    https://social.technet.microsoft.com/wiki/contents/articles/18894.how-to-get-the-textual-representation-of-a-number-convert-number-to-words-in-vb-net.aspx

    Reed Kimble set that up a while back.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    • Proposed as answer by Cor Ligthert Monday, August 14, 2017 9:08 AM
    Friday, August 11, 2017 3:52 PM
  • Hirei's,

    Based on your code, if you enter 15014, do you want to output " Ten fifteen thousand zero hundred one ten four"?

    If yes, you may need to modify you code.

    Select Case Input >= 10000 And Input <= 99999
                Case True
                    one = Input \ 1000 Mod 10
                    tenthousands = Input \ 10000
                    hundreds = Input \ 100 Mod 10
                    tens = Input \ 10 Mod 10
                    ones = Input Mod 10000 Mod 10
                    teens = Input Mod 100
                    firstteens = Input \ 1000
    
                    Select Case tenthousands
                        Case 1
                            outTenthousands = "Ten"
                        Case 2
                            outTenthousands = "Twenty"
                        Case 3
                            outTenthousands = "Thirty"
                        Case 4
                            outTenthousands = "Fourty"
                        Case 5
                            outTenthousands = "Fifty"
                        Case 6
                            outTenthousands = "Sixty"
                        Case 7
                            outTenthousands = "Seventy"
                        Case 8
                            outTenthousands = "Eighty"
                        Case 9
                            outTenthousands = "Ninety"
                    End Select
                    Select Case firstteens
                        Case 11
                            outOne = "Eleven"
                        Case 12
                            outOne = "Twelve"
                        Case 13
                            outOne = "Thirteen"
                        Case 14
                            outOne = "Fourteen"
                        Case 15
                            outOne = "Fifteen"
                        Case 16
                            outOne = "Sixteen"
                        Case 17
                            outOne = "Seventeen"
                        Case 18
                            outOne = "Eightteen"
                        Case 19
                            outOne = "Nineteen"
                        Case 20
                            outOne = "Twenty"
                    End Select
                    Select Case hundreds
                        Case 0
                            outHundreds = "Zero"
                        Case 1
                            outHundreds = "One"
                        Case 2
                            outHundreds = "Two"
                        Case 3
                            outHundreds = "Three"
                        Case 4
                            outHundreds = "Four"
                        Case 5
                            outHundreds = "Five"
                        Case 6
                            outHundreds = "Six"
                        Case 7
                            outHundreds = "Seven"
                        Case 8
                            outHundreds = "Eight"
                        Case 9
                            outHundreds = "Nine"
                    End Select
                    Select Case tens
                        Case 0
                            outTens = "Zero"
                        Case 1
                            outTens = "One"
                        Case 2
                            outTens = "Two"
                        Case 3
                            outTens = "Three"
                        Case 4
                            outTens = "Four"
                        Case 5
                            outTens = "Five"
                        Case 6
                            outTens = "Six"
                        Case 7
                            outTens = "Seven"
                        Case 8
                            outTens = "Eigh"
                        Case 9
                            outTens = "Nine"
                    End Select
                    Select Case ones
                        Case 0
                            outones = "Zero"
                        Case 1
                            outones = "One"
                        Case 2
                            outones = "Two"
                        Case 3
                            outones = "Three"
                        Case 4
                            outones = "Four"
                        Case 5
                            outones = "Five"
                        Case 6
                            outones = "Six"
                        Case 7
                            outones = "Seven"
                        Case 8
                            outones = "Eight"
                        Case 9
                            outones = "Nine"
                    End Select
                    Select Case actualInput > 0
                        Case True
                            lblOutput.Text = outTenthousands & " " & outOne & " Thousand " & outHundreds & " Hundred " & outTens & " Ten " & outones
                        Case False
                            lblOutput.Text = "Negative " & outTenthousands & " " & outOne & " Thousand " & outHundreds & " " & outTens & " " & outones
                    End Select
            End Select

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 8:57 AM
    Moderator