Results 1 to 2 of 2

Type Mismatch when trying to multiply arrays within function

Threaded View

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    NV
    MS-Off Ver
    Excel 2003
    Posts
    1

    Type Mismatch when trying to multiply arrays within function

    I am passing two double arrays to a function that multiplies them together at corresponding indexes and sends back the sum of all products as a double. I know that the function treats the arrays as variant/double arrays but my understanding was that this did not matter. I appreciate your advice and criticism ahead of time. By the way, this code is almost a direct translation from Fortran77 and I am trying to change as little as possible.

    Option Explicit
    Option Base 1
    Function DOT(AA, BB, n)
        Dim i As Integer
        Dim DUM1 As Double
        DOT = 0#
        For i = 1 To n
            DUM1 = AA(i) * BB(i)
            DOT = DOT + DUM1
        Next
    End Function
    At line 8, AA(i) and BB(i) are coming up as type mismatch. AA and BB are passed in as double arrays and n is passed in as an integer.

    Edit: I just realized I was passing in a doubles and not the entire array. Code was fine after all. Thank you please delete this thread if needed.
    Last edited by weekendwarrior; 07-24-2012 at 03:07 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1