Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numbers to Roman Numerals Converter
#2
Nice, reminds me of the change maker I did.

Making it a function called Romanize$(number):
Code: (Select All)
'Thanks to ChatGPT for a little help figuring this out. I fixed the DIM numbers and removed the Function and made the code simpler.
'By SierraKen on Aug. 12, 2024
'I been wanting to make this since the 1990's! LOL

' mod b+ 2024-08-12
_Title "Numbers To Roman Numerals Converter"
For i = 1 To 3999
    Print i, Romanize$(i)
    If i Mod 20 = 19 Then Print "Sleeping ...zzz, press any": Sleep: Cls
Next

Function Romanize$ (number As Integer)
    Dim values(13) As Integer
    Dim symbols(13) As String

    If number < 1 Or number > 3999 Then
        Romanize$ = "Number out of range. Please enter a number between 1 and 3999."
    Else
        values(1) = 1000: symbols(1) = "M"
        values(2) = 900: symbols(2) = "CM"
        values(3) = 500: symbols(3) = "D"
        values(4) = 400: symbols(4) = "CD"
        values(5) = 100: symbols(5) = "C"
        values(6) = 90: symbols(6) = "XC"
        values(7) = 50: symbols(7) = "L"
        values(8) = 40: symbols(8) = "XL"
        values(9) = 10: symbols(9) = "X"
        values(10) = 9: symbols(10) = "IX"
        values(11) = 5: symbols(11) = "V"
        values(12) = 4: symbols(12) = "IV"
        values(13) = 1: symbols(13) = "I"
        romanNum$ = ""
        num = number
        For i = 1 To 13
            While num >= values(i)
                romanNum$ = romanNum$ + symbols(i)
                num = num - values(i)
            Wend
        Next i
        Romanize$ = romanNum$
    End If
End Function
b = b + ...
Reply


Messages In This Thread
RE: Numbers to Roman Numerals Converter - by bplus - 08-12-2024, 11:23 PM



Users browsing this thread: 5 Guest(s)