A simple program that I wrote using Visual Basic 5 to accept decimal number from the user and then our program will convert the given number into it's roman numeral equivalent. The code is very short and easy to understand.
My mobile number here in the Philippines is 09173084360.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
Function Convert_To_Roman(value) As String
Dim arabic As Variant
Dim roman As Variant
arabic = Array(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
roman = Array("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I")
Dim i As Integer, result As String
For i = 0 To 12
Do While value >= arabic(i)
result = result + roman(i)
value = value - arabic(i)
Loop
Next i
Convert_To_Roman = result
End Function
Private Sub Command1_Click()
Label3.Caption = "The Roman Numeral Equivalent of " & Val(Text1.Text) _
& " is " & Convert_To_Roman(Val(Text1.Text)) & "."
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub
No comments:
Post a Comment