guckst du:
Sub Click(Source As Button)
Msgbox RomToArab ("III")
End Sub
Function RomToArab(r As String) As Integer
Dim p As Integer
Dim z As String
If Len(r) = 1 Then
Select Case r
Case "I"
RomToArab = 1
Case "V"
RomToArab = 5
Case "X"
RomToArab = 10
Case "L"
RomToArab = 50
Case "C"
RomToArab = 100
Case "D"
RomToArab = 500
Case "M"
RomToArab = 1000
End Select
Elseif Len(r) = 0 Then '2. Basisklausel
RomToArab = 0
Else 'rekursive Klausel
search_max r, z, p
RomToArab = RomToArab(z) - _
RomToArab(Mid(r, 1, p - 1)) + _
RomToArab(Mid(r, p + 1, 1000))
End If
End Function
Sub search_max(r As String, z As String, p As Integer)
Dim i As Integer
Dim j As Integer
Const f = "MDCLXVI"
For i = 1 To Len(f)
For j = 1 To Len(r)
If Mid(r, j, 1) = Mid(f, i, 1) Then
p = j
z = Mid(f, i, 1)
Exit Sub
End If
Next j
Next i
End Sub
Das sollte sich doch irgendwie in die Maske integrieren lassen...