Microsoft Small Basic

Program Listing:
Embed this in your website
char[1][1] = "I"
char[1][2] = "V"
char[2][1] = "X"
char[2][2] = "L"
char[3][1] = "C"
char[3][2] = "D"
char[4][1] = "M"

While ("True")
  TextWindow.WriteLine("Enter number to convert to Roman Numerals")
  number = TextWindow.ReadNumber()

  If (number > 0 And number < 4000) Then
    output = ""
    For i = 1 To Text.GetLength(number)
      digit = Text.GetSubText(number,Text.GetLength(number)+1-i,1)
      convert()
    EndFor

    TextWindow.WriteLine("")
    TextWindow.WriteLine(output)
    TextWindow.WriteLine("")
  Else
    TextWindow.WriteLine("Try again between 1 and 3999")
  EndIf
EndWhile

Sub convert
  If (digit = 1) Then
    numeral = char[i][1]
  ElseIf (digit = 2) Then
    numeral = char[i][1]+char[i][1]
  ElseIf (digit = 3) Then
    numeral = char[i][1]+char[i][1]+char[i][1]
  ElseIf (digit = 4) Then
    numeral = char[i][1]+char[i][2]
  ElseIf (digit = 5) Then
    numeral = char[i][2]
  ElseIf (digit = 6) Then
    numeral = char[i][2]+char[i][1]
  ElseIf (digit = 7) Then
    numeral = char[i][2]+char[i][1]+char[i][1]
  ElseIf (digit = 8) Then
    numeral = char[i][2]+char[i][1]+char[i][1]+char[i][1]
  ElseIf (digit = 9) Then
    numeral = char[i][1]+char[i+1][1]
  Else
    numeral = ""
  EndIf
  output = numeral+output
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.