Results 1 to 11 of 11

Thread: Logarithms

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    I tried using the Log(x) function but it keeps giving me an error saying "expected array". i'm using a Double type variable for x. thanks for any help.

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Try changing the variable name from x to n.

  3. #3

  4. #4
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Assuming you still have the Log Function (ie a type library hasn't dissapeared for some reason) the only thing I can think of is that X is the name of an array and you forgot to specify an index

    for example is x declared like any of these
    Code:
    Dim x() As Double
    Dim x(a) As Double
    Dim x(a To b) as double
    where a and b are numbers or constants (not variables you'd have got an error)

    If this isn't what you've done then type "Print Math." into the debug window, you should get a picklist with Log in it somewhere, if you don't get one search your object browser for Math and Log, if you don't find the log function try reinstallin VB.

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Can you post your code so we can see the whole picture please?
    Mark
    -------------------

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    says "expected variable or procedure not module" when i did print math.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    Dim i As Integer, j As Integer
    Log = True
    For i = 1 To Curves
    For j = 1 To Crve(i).Num
    Crve(i).Sets(j).Omega = Log(Crve(i).Sets(j).Omega)
    Next j
    Next i
    Call DrawGraph(-1, 0, 0)



    It's a graphing program, i'm trying to convert numbers from an array into log's. i tried doing it with simple non-array variables too though. by the way i searched for math and log in object browser and found both.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    how does everyone post code so that it looks like code?

  9. #9
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I see the problem, you've put Log = True for some reason at the top of your code, so VB thinks that you are using Log as a variable, then when you typ Log(x) it objects because it thinks that you want to use your Log Variable as an array and not that you want to use the Log function, get rid of the Log = True Line and it should work.

    BTW you can get your code to look like code by enclosing it in Code Tags, put

    [code@]
    Dim i As Integer
    [/code@]

    but without the @ characters and it comes out

    Code:
    Dim i As Integer

    see http://forums.vb-world.net/index.php?action=bbcode for other tags

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    thanks, you're right

  11. #11
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Try always to write "Option Explicit" at the beginning of each code.
    This ensures the compiler that al variables must be defined with the Dim statement or within Subs, Functions, ...
    You can set this as an option in the VB environment.

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