|
|
|
|
|
Dicas
|
|
Visual Basic (Operações Matemáticas)
|
|
|
Título da Dica: Converter Numero Decimal em Numero Romano
|
|
|
|
Postada em 31/8/2003 por Ð@®l@n
Function Num2Roman(ByVal N As Integer) As String ' ' Converts a decimal number into a Roman number ' Valid input in the range 1-3999 ' Const Digits = "IVXLCDM" Dim i As Integer, Digit As Integer, Temp As String i = 1 Temp = "" Do While N > 0 Digit = N Mod 10 N = N \ 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 Num2Roman = Temp End Function
Private Sub Command1_Click() MsgBox Num2Roman(12) End Sub
|
|
|
|
|