# Microsoft Small Basic

Program Listing:
digits[1] = "1=one ;2=two ;3=three ;4=four ;5=five ;6=six ;7=seven ;8=eight ;9=nine "
teensdigits = "0=ten ;1=eleven ;2=twelve ;3=thirteen ;4=fourteen ;5=fifteen ;6=sixteen ;7=seventeen ;8=eighteen ;9=nineteen "
digits[2] = "1=ten ;2=twenty ;3=thirty ;4=forty ;5=fifty ;6=sixty ;7=seventy ;8=eighty ;9=ninety "
For i = 1 To 9
digits[3][i] = digits[1][i]+"hundred "
digits[4][i] = digits[1][i]+"thousand "
digits[5][i] = digits[2][i]
digits[6][i] = digits[3][i]
digits[7][i] = digits[1][i]+"million "
digits[8][i] = digits[2][i]
digits[9][i] = digits[3][i]
EndFor
digits[4][0] = "thousand "
While 1=1
txt = ""
TextWindow.Clear()
TextWindow.WriteLine("Enter a number to write in word form:")
length = Text.GetLength(num)
For i = 1 To 3
digitentered[i] = Text.GetSubText(num,length-i+1,1)
If Math.Remainder(i,3) = 2 And digitentered[i] = 1 Then
txt[1] = teensdigits[digitentered[i-1]]
Else
txt[1] = Text.Append(digits[i][digitentered[i]],txt[1])
EndIf
EndFor
For i = 4 To 6
digitentered[i] = Text.GetSubText(num,length-i+1,1)
If Math.Remainder(i,3) = 2 And digitentered[i] = 1 Then
txt[2] = teensdigits[digitentered[i-1]]+"thousand "
Else
txt[2] = Text.Append(digits[i][digitentered[i]],txt[2])
EndIf
EndFor
For i = 7 To 9
digitentered[i] = Text.GetSubText(num,length-i+1,1)
If Math.Remainder(i,3) = 2 And digitentered[i] = 1 Then
txt[3] = teensdigits[digitentered[i-1]]+"million "
Else
txt[3] = Text.Append(digits[i][digitentered[i]],txt[3])
EndIf
EndFor
txt = txt[3]+txt[2]+txt[1]
TextWindow.WriteLine(txt)
Program.Delay(4000)
EndWhile