Dim Roman As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'RomanNumber(CInt(txtNumber.Text))
lblRoman.Text = ""
RomanNumber(CInt(InputBox("Please enter the number")))
lblRoman.Text = Roman
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function RomanNumber(ByVal Number As Integer) As String
Try
Do While Number > 0
Select Case Number
Case Is >= 1000
Roman &= "M"
Number -= 1000
Case Is >= 900
Roman &= "CM"
Number -= 900
Case Is >= 500
Roman &= "D"
Number -= 500
Case Is >= 400
Roman &= "CD"
Number -= 400
Case Is >= 100
Roman &= "C"
Number -= 100
Case Is >= 90
Roman &= "XC"
Number -= 90
Case Is >= 50
Roman &= "L"
Number -= 50
Case Is >= 40
Roman &= "XL"
Number -= 40
Case Is >= 10
Roman &= "X"
Number -= 10
Case 9
Roman &= "IX"
Number -= 9
Case 5 To 8
Roman &= "V"
Number -= 5
Case 4
Roman &= "IV"
Number -= 4
Case 1 To 3
Roman &= "I"
Number -= 1
End Select
Loop
Return Roman
Catch ex As Exception
MessageBox.Show(ex.Message, "Emint msgbox...!")
End Try
End Function
End Class
Subscribe to:
Post Comments (Atom)
1 comment:
useful post thanks
Post a Comment