Problemstellung:
Für 32Bit und 64Bit Office Versionen
Wie kann ich aus einer Zahl eine römische Zahl machen?
Function Dec2Romanum(ByVal Zahl As Integer) As String ' Konvertiert eine Zahl in entsprechende römische Zahl Const Digits = "IVXLCDM" Dim i As Integer, Digit As Integer, Temp As String i = 1 Temp = "" Do While Zahl > 0 Digit = Zahl Mod 10 Zahl = Zahl \ 10 Select Case Digit Case 1 Temp = Mid(Digits, i, 1) & Temp Case 2 Temp = Mid(Digits, i, 1) & Mid(Digits, i, 1) & Temp Case 3 Temp = Mid(Digits, i, 1) & Mid(Digits, i, 1) & Mid(Digits, i, 1) & Temp Case 4 Temp = Mid(Digits, i, 2) & Temp Case 5 Temp = Mid(Digits, i + 1, 1) & Temp Case 6 Temp = Mid(Digits, i + 1, 1) & Mid(Digits, i, 1) & Temp Case 7 Temp = Mid(Digits, i + 1, 1) & Mid(Digits, i, 1) & Mid(Digits, i, 1) & Temp Case 8 Temp = Mid(Digits, i + 1, 1) & Mid(Digits, i, 1) & Mid(Digits, i, 1) & Mid(Digits, i, 1) & Temp Case 9 Temp = Mid(Digits, i, 1) & Mid(Digits, i + 2, 1) & Temp End Select i = i + 2 Loop Dec2Romanum = Temp End Function
Aufruf:
Dim x As String x = Dec2Romanum(1963)
würde die Zahl 1963 in MCMLXIII umwandeln
Ähnliche Artikel
Weiterlesen...