I have encountered a block in my programming escapade. The project that I am working on is from a visual basic 6.0 programming book and is a program that opens a data file filled with roman numerals, read to end of file, and outputs the numerals digit form, performs a mathematical operator on them, and then display output. I am also employing the use of subfunctions/subroutines to better organize my program. Below are my subs.

ReadRoman - Reads a string which represents a Roman Number, calls GetDigit to convert this Roman Digit into a decimal number, adds this decimal number to the value of the roman number.

GetDigit = Takes a roman digit and returns the decimal value to the caller.

Calculate - Takes the decimal equivalent of both Roman numbers and the operator and computes their combined result. Uses WriteRoman to display the last line of output.

WriteRoman - Takes a decimal number and converts it into a Roman Nubmer. Calls Writedigit in order to accomplish the above.

WriteDigit - Print a Roman Digit

To better explain it, I have included the data file as well as a little preview of what I would like to output.

Output

The First Numer is 1226
The second number is 68
The Operation is +
MCCXXVI + LXVIII = MCCLXXXXIIII (1294)

The DAT file is organized as seen below.[ATTACH]104365[/ATTACH]

(Start of File)

MCCXXVI
LXVIII
+
MCCXXVI

LXVIII

MCCXXVI
XVII
*
DCI
L
MDCIIII
L
*
CCCC

XXXX

(End of File)

Here is the code that I have so far. (I apologize for pastebin link, had trouble attempting to embed into this post)

http://pastebin.com/NtV4tbzZ

Dim numerals As String
Private Function ReadRoman()
End Function
Private Function GetDigit(ByVal Num As String) As Integer
 Select Case Num
    Case "I"
        GetDigit = 1
    Case "V"
        GetDigit = 5
    Case "X"
        GetDigit = 10
    Case "L"
        GetDigit = 50
    Case "C"
        GetDigit = 100
    Case "D"
        GetDigit = 500
    Case "M"
        GetDigit = 1000
End Select
End Function

Private Function WriteRoman()
Call WriteDigit
output.Print Number
End Function
Private Function WriteDigit()
output.Print numerals
End Function

Private Sub calculate_Click()
Input #1, numerals
For i = 1 To Len(numerals)
End Sub

Private Sub Form_Load()
'open file
Open App.Path & "\numerals.dat" For Input As #1
'Do While Not EOF(1)
End Sub

Thank you for your time, and I apologize for any grammatical errors and lack of programming experience.

Recommended Answers

All 2 Replies

I'm sending a PM

Code is looking good.
Here are the rules I found for writting Roman Numerals

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.