September 7th, 2013, 01:35 PM
[Help] Stuck on Program
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.
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.Attachment 104365
(Start of File)
(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)
Thank you for your time, and I apologize for any grammatical errors and lack of programming experience.
Dim numerals As String
Private Function ReadRoman()
Private Function GetDigit(ByVal Num As String) As Integer
Select Case Num
GetDigit = 1
GetDigit = 5
GetDigit = 10
GetDigit = 50
GetDigit = 100
GetDigit = 500
GetDigit = 1000
Private Function WriteRoman()
Private Function WriteDigit()
Private Sub calculate_Click()
Input #1, numerals
For i = 1 To Len(numerals)
Private Sub Form_Load()
Open App.Path & "\numerals.dat" For Input As #1
'Do While Not EOF(1)
September 8th, 2013, 12:58 AM
Re: [Help] Stuck on Program
We don't do homework here. Google that, and you'll find many samples. Don't hand them in, though.
September 9th, 2013, 08:18 AM
Re: [Help] Stuck on Program
It is unfortunately a tad more difficult than that. The problem you have now is that you have to literally check each character on input to determine some sort of macth to your Roman numerals. You would have to put the roman numerals inside arrays then loop through them. As in the attached example.
I did not make this app, so I cannot and will not take credit for it. If you were to search on CG you will find it
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!