Results 1 to 11 of 11

Thread: Please help with this array!

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    1

    Exclamation 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
    Last edited by DutchBird; Jun 5th, 2002 at 05:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width