Please help with this array!
I have to make a project, in wich I have to convert Roman numbers (e.g. XIV) into "normal" numbers (e.g. 1,2,3). An array should cover it, but I really can't find out how it works.
Please Help Me!
ps
Maybe you can help me with the code?:)
Thanks everybody, It worked! Here is the code:
(some is in Dutch, but you'll get the genaral idea)
'Declarations Roman Numbers
Dim RomijnArray(10) As String
Dim RomLetter As String
Dim Romijnsstring As String
'delaraties arab cijfers
Dim ArabLetter1 As Integer
Dim ArabLetter2 As Integer
Dim ArabArray(10) As Integer
'declaraties totaal
Dim alles As Integer
Romijnsstring = UCase(txtRomeinsveld.Text)
l = Len(Romijnsstring)
alles = 0
For i = 1 To l
RomijnArray(i) = Mid(Romijnsstring, i, 1)
Next
For i = 1 To l
RomLetter = RomijnArray(i)
If RomLetter = "I" Then
ArabArray(i) = 1
ElseIf RomLetter = "V" Then
ArabArray(i) = 5
ElseIf RomLetter = "X" Then
ArabArray(i) = 10
ElseIf RomLetter = "L" Then
ArabArray(i) = 50
ElseIf RomLetter = "C" Then
ArabArray(i) = 100
ElseIf RomLetter = "D" Then
ArabArray(i) = 500
ElseIf RomLetter = "M" Then
ArabArray(i) = 1000
Else
MsgBox "Wrong number", vbExclamation
Exit Sub
End If
Next
For i = 1 To l
ArabLetter1 = ArabArray(i)
ArabLetter2 = ArabArray(i + 1)
If ArabLetter1 < ArabLetter2 Then
alles = alles - ArabLetter1
ElseIf ArabLetter1 > ArabLetter2 Or ArabLetter1 = ArabLetter2 Then
alles = alles + ArabLetter1
Else
MsgBox "Wrong Number", vbExclamation
Exit Sub
End If
Next
txtArabischveld.Text = alles
End Sub
Re: Please help with this array!
Quote:
Originally posted by DutchBird
I have to make a project, in wich I have to convert Roman numbers (e.g. XIV) into "normal" numbers (e.g. 1,2,3). An array should cover it, but I really can't find out how it works.
Please Help Me!
ps
Maybe you can help me with the code?:)
Are you sure you really need array,
Can you explain me some...or
I can help you
Gary