How to Make a Roman Numerals Converter in VB Code
The Visual Basic language does not have an automatic Roman numerals converter, so you must manually set up a set of "switch" statements that determine the numeric value and change the numeric value to a Roman numeral string. You use this function to display numbers in Roman numeral format on a Web or desktop application.
Instructions
-
-
1
Open your Visual Studio software and open the Visual Basic project. Double-click the file you want to use to create the conversion function.
-
2
Create the string value that you use to contain the roman numeral value. The following code creates a VB.NET string:
Dim roman As String
-
-
3
Set up the switch statement to go through a list of possible values and convert the number to the roman numeral. You must create a case for each number possibility you want to use. For instance, the following code sets up a switch statement for the numbers 1 to 3:
Select Case numberInput
Case 1
roman = "I"
Case 2
roman = "II"
Case 3
roman = "III"
End SelectThe "numberInput" variable is the input from your users. Replace this variable with the name of the variable you use to contain input from users.
-
4
Display the roman numeral conversion. The following code displays the converted number:
WriteLine("Converted Number: " & roman)
-
1