SHARED Array values with SUBs and FUNCTIONs
#11
KP "No!"  no my code runs fine!

Why are you changing the ReDim's to 2 for lower bound?
   

My code ran fine here is indy test of it to show the final values as correct:
Code: (Select All)
Dim Shared mySharedArray(1 To 20) As Long

For i = 1 To 20
    mySharedArray(i) = i * i
Next

ReDim out10(1 To 10) As Integer
first10Plus5 = first10squaresPlus&(5, out10())
For i = 1 To 10
    Print i ^ 2 + 5, out10(i)
    tot2 = tot2 + i ^ 2 + 5
Next
Print "Total was: "; first10Plus5
Print "Tot2 check my sub total"; tot2

Function first10squaresPlus& (X, outputFirst10() As Integer)
    For i = 1 To 10
        outputFirst10(i) = mySharedArray(i) + X
        tot& = tot& + outputFirst10(i)
    Next
    first10squaresPlus& = tot&
End Function
   
b = b + ...
Reply


Messages In This Thread
RE: SHARED Array values with SUBs and FUNCTIONs - by bplus - 06-22-2023, 06:51 PM



Users browsing this thread: 7 Guest(s)