longkd_bvct@yahoo.com.vn > 21-08-21, 10:14 AM
tranthanhan1962 > 21-08-21, 10:52 AM
longkd_bvct@yahoo.com.vn > 21-08-21, 11:25 AM
paulsteigel > 21-08-21, 11:08 PM
(21-08-21, 11:25 AM)longkd_bvct@yahoo.com.vn Đã viết: Dạ em cám ơn anh nhé
' Formats a number as a roman numeral.
' Author: Christian d'Heureuse (www.source-code.biz)
Public Function FormatRoman(ByVal n As Integer) As String
If n = 0 Then FormatRoman = "0": Exit Function
' There is no roman symbol for 0, but we don't want to return an empty string.
Const r = "IVXLCDM" ' roman symbols
Dim i As Integer: i = Abs(n)
Dim s As String, p As Integer
For p = 1 To 5 Step 2
Dim d As Integer: d = i Mod 10: i = i \ 10
Select Case d ' format a decimal digit
Case 0 To 3: s = String(d, Mid(r, p, 1)) & s
Case 4: s = Mid(r, p, 2) & s
Case 5 To 8: s = Mid(r, p + 1, 1) & String(d - 5, Mid(r, p, 1)) & s
Case 9: s = Mid(r, p, 1) & Mid(r, p + 2, 1) & s
End Select
Next
s = String(i, "M") & s ' format thousands
If n < 0 Then s = "-" & s ' insert sign if negative (non-standard)
FormatRoman = s
End Function
tranthanhan1962 > 22-08-21, 10:36 AM