asp.net - Convert numerical amount to words in vb.net showing Type Expected error -


i trying convert numeric numbers words in vb.net. somewhere getting type expected error. below entire code. putting code separately error coming.

public shared function convertnumbertowords(number integer) string     if number = 0         return "zero"     end if     if number < 0         return convert.tostring("minus ") & convertnumbertowords(math.abs(number))     end if     dim words string = ""     if (number / 1000000) > 0         words += convertnumbertowords(number / 1000000) & convert.tostring(" million ")         number = number mod 1000000     end if     if (number / 1000) > 0         words += convertnumbertowords(number / 1000) & convert.tostring(" thousand ")         number = number mod 1000     end if     if (number / 100) > 0         words += convertnumbertowords(number / 100) & convert.tostring(" hundred ")         number = number mod 100     end if     if number > 0         if words <> ""             words += "and "         end if         dim unitsmap = new () {"zero", "one", "two", "three", "four", "five",             "six", "seven", "eight", "nine", "ten", "eleven",             "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",             "eighteen", "nineteen"}         dim tensmap = new () {"zero", "ten", "twenty", "thirty", "forty", "fifty",             "sixty", "seventy", "eighty", "ninety"}          if number < 20             words += unitsmap(number)         else             words += tensmap(number / 10)             if (number mod 10) > 0                 words += " " + unitsmap(number mod 10)             end if         end if     end if     return words end function 

in below line getting type expected error

dim unitsmap = new () {"zero", "one", "two", "three", "four", "five",                 "six", "seven", "eight", "nine", "ten", "eleven",                 "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",                 "eighteen", "nineteen"}             dim tensmap = new () {"zero", "ten", "twenty", "thirty", "forty", "fifty",                 "sixty", "seventy", "eighty", "ninety"} 

you getting error because not specifying type of array declare.i got no error when tried this

  dim unitsmap  = new string() {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen","eighteen", "nineteen"} 

hope helps.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -