How is Eval() to be used in VBA?

Discussion in 'AutoCAD' started by DaveyT, Nov 11, 2007.

  1. DaveyT

    DaveyT Guest

    Hi guys.
    I have a problem which I think can be solved if I use Eval()
    correctly. But I don't know how.

    Here's some code which is in principal what I need to work:

    Sub Test()

    Dim TestString As String
    Dim Variable01Test As Variant
    Dim Variable02Test As Variant
    Dim Variable03Test As Variant
    Dim Variable04Test As Variant
    Dim Variable05Test As Variant
    Dim Number As Integer

    Variable01Test = 10
    Variable02Test = 20
    Variable03Test = 30
    Variable04Test = 40
    Variable05Test = 50

    For i = 0 To 4

    Number = i + 1

    TestString = "Variable0" & Number & "Test"
    MsgBox "TestString = " & TestString, 64, "TestString!"
    MsgBox "Value of Variable" & Number & "Test is: " & Eval(TestString),
    64, "Test!"

    Next i

    End Sub

    I just get an error message...
    Can anyone help
     
    DaveyT, Nov 11, 2007
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.