For the past two hours I was searching for a built-in function for converting an integer to an equivalent Roman numeral, but it failed to achieve the target. Hence I wrote my own routine for performing this conversion. I think it needs some more clarifications.
Public Class Form1
Dim ind() As Integer = {1, 2, 3, 4, 5, 10, 50, 100, 500, 1000}
Dim rom() As String = {"I", "II", "III", "IV", "V", "X", "L", "C", "D", "M"}
Dim limit As Integer = 9
Dim output As String = ""
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num As Integer
output = ""
num = CInt(txt1.Text)
While num > 0
num = find(num)
End While
txt2.Text = output
End Sub
Public Function find(ByVal Num As Integer) As Integer
Dim i As Integer = 0
While ind(i) <= Num
i += 1
End While
If i <> 0 Then
limit = i - 1
Else
limit = 0
End If
output = output & rom(limit)
Num = Num - ind(limit)
Return Num
End Function
End Class
Note: This function can only be used for range of 1-999
IndexOutOfRangeException
at the first run. Try enter1234
. \$\endgroup\$