# Decimal to roman numeral converter in vb.net

Vb program for Decimal to roman numeral converter. Here more solutions.

``````' Include namespace system
Imports System
'  Vb.net program for
'  Conversion from Decimal to roman number
public Class Perform
' Display roman value of n
Public Shared Sub result(ByVal n As Integer)
Select Case (n)
' Test Cases
Case 1
Console.Write("I")
Case 4
Console.Write("IV")
Case 5
Console.Write("V")
Case 9
Console.Write("IX")
Case 10
Console.Write("X")
Case 40
Console.Write("XL")
Case 50
Console.Write("L")
Case 90
Console.Write("XC")
Case 100
Console.Write("C")
Case 400
Console.Write("CD")
Case 500
Console.Write("D")
Case 900
Console.Write("DM")
Case 1000
Console.Write("M")
End Select
End Sub
Public Shared Function  selecting(ByVal number As Long,
ByVal collection As Integer(),
ByVal size As Integer) As Long
Dim n As Integer = 1
Dim i As Integer = 0
With Nothing
i = 0
While i < size
if (number >= collection(i)) Then
n = collection(i)
Else
Exit While
End IF
End While
End With
result(n)
' Reduce the value of number
Return  number - n
End Function
Public Shared Sub romanNo(ByVal number As Long)
if (number <= 0) Then
' When is not a natural number
Return
End If
' Base case collection
Dim collection As Integer() =
{1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000}
' Get the size of collection
Dim size As Integer = collection.Length
Console.Write(" {0} : ",number)
while (number > 0)
number = selecting(number, collection, size)
End While
Console.WriteLine()
End Sub
Public Shared Sub Main(ByVal args As String())
' Test Case
romanNo(10)
romanNo(18)
romanNo(189)
romanNo(604)
romanNo(982)
romanNo(3000)
End Sub
End Class``````

Output

`````` 10 : X
18 : XVIII
189 : CLXXXIX
604 : DCIV
982 : DMLXXXII
3000 : MMM``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.