none
Public Sub Call Problem " Type mismatch:array or user -defined type expected" RRS feed

  • Question

  • I receive error when I call Sub from another. Error message " Type mismatch:array or user -defined type expected". Here is code, I call Sub "MATA1" from Sub "Run_MATA":

    Public Sub Run_MATA() Dim MNBK(3) As Double Dim GPP(), C(), PVT(7), P(), ANP(), GP(), WP(), BO(), BG(), RS(), WPI() As Double Dim IRLDT(3) As Double Dim BT() As Double, RP() As Double, F() As Double, EO() As Double, EG() As Double Dim EF() As Double, G7() As Double, FE() As Double, WNE() As Double, T() As Double Dim BGG() As Double, WNI() As Double, E() As Double, SIGMA() As Double 'Set Mat = New Mata.Mata For I = 0 To 3 MNBK(I) = Sheets("TAPE5").Cells(2, I + 1).Value IRLDT(I) = Sheets("TAPE5").Cells(26, I + 1).Value Next I ReDim GPP(MNBK(1) - 1) ReDim C(MNBK(0) - 1) ReDim P(MNBK(1) - 1) ReDim ANP(MNBK(1) - 1) ReDim GP(MNBK(1) - 1) ReDim WP(MNBK(1) - 1) ReDim BO(MNBK(1) - 1) ReDim BG(MNBK(1) - 1) ReDim RS(MNBK(1) - 1) ReDim WPI(MNBK(1) - 1) For I = 0 To MNBK(1) - 1 GPP(I) = Sheets("TAPE5").Cells(4, I + 1).Value P(I) = Sheets("TAPE5").Cells(10, I + 1).Value ANP(I) = Sheets("TAPE5").Cells(12, I + 1).Value GP(I) = Sheets("TAPE5").Cells(14, I + 1).Value WP(I) = Sheets("TAPE5").Cells(16, I + 1).Value BO(I) = Sheets("TAPE5").Cells(18, I + 1).Value BG(I) = Sheets("TAPE5").Cells(20, I + 1).Value RS(I) = Sheets("TAPE5").Cells(22, I + 1).Value WPI(I) = Sheets("TAPE5").Cells(24, I + 1).Value Next I For I = 0 To MNBK(0) - 1 C(I) = Sheets("TAPE5").Cells(6, I + 1).Value Next I For I = 0 To 7 PVT(I) = Sheets("TAPE5").Cells(8, I + 1).Value Next I Call MATA1(MNBK, GPP, C, PVT, P, ANP, GP, WP, BO, BG, RS, WPI, IRLDT, BT, RP, F, EO, EG, EF, G7, FE, WNE, T, BGG, WNI, E, SIGMA) K = "KK" End Sub Public Sub MATA1(ByRef MNBK() As Double, ByRef GPP() As Double, ByRef C() As Double, ByRef PVT() As Double, ByRef P() As Double, ByRef ANP() As Double, _ ByRef GP() As Double, ByRef WP() As Double, ByRef BO() As Double, ByRef BG() As Double, ByRef RS() As Double, ByRef WPI() As Double, _ IRLDT() As Double, ByRef BT() As Double, ByRef RP() As Double, ByRef F() As Double, ByRef EO() As Double, ByRef EG() As Double, _ ByRef EF() As Double, ByRef G7() As Double, ByRef FE() As Double, ByRef WNE() As Double, ByRef T() As Double, _ ByRef BGG() As Double, ByRef WNI() As Double, ByRef E() As Double, ByRef SIGMA() As Double) Dim M, NAMB, KONT, N, K, MA, IR, L, LL, KII, NA As Integer Dim T1, B, BTO, BOO, PO, BGO, RSO, MGO, SWI, CW, CS, DP, CO, SO, C1, DT As Double Dim DEP(), TI(), DE(), G(), XY(), XKV(), SY(), SX(), SXY(), SXKV(), Y(), D() As Double Dim A38, A39, A40, A41, A43, A44, SUMA As Double M = MNBK(0) - 1 N = MNBK(1) - 1 NAMB = MNBK(2) KONT = MNBK(3) PO = PVT(0) BOO = PVT(1) BGO = PVT(2) RSO = PVT(3) MGO = PVT(4) SWI = (5) CW = PVT(6) CS = PVT(7) IR = IRLDT(0) L = IRLDT(1) LL = IRLDT(2) DT = IRLDT(3) K = 0 'K=1 MA = 0 T1 = 0# B = 1# TI(K) = 0# BTO = BOO DEP(K) = PO - P(1) For I = 0 To N ' DO 10 I=1,N DP = PO - P(I) If GPP(I) = 0 Then GoTo 7 GP(I) = ANP(I) * GPP(I) 7: BT(I) = BO(I) + (RSO - RS(I)) * BG(I) RP(I) = GP(I) / ANP(I) F(I) = ANP(I) * (BT(I) + BG(I) * (RP(I) - RSO)) + WP(I) - WPI(I) EO(I) = BT(I) - BTO EG(I) = BG(I) - BGO EF(I) = ((BTO / (1# - SWI)) * (CS + CW * SWI)) * DP G7(I) = MGO * (BTO / BGO) 'Write(6, 401) BT,RP(I),F(I),EO,EG,EF,G7 '401 FORMAT(1H ,7E17.6) If NAMB = 1 Then GoTo 2 If NAMB = 2 Then GoTo 3 If NAMB = 3 Then GoTo 4 If NAMB = 4 Then GoTo 5 If NAMB = 5 Then GoTo 6 If NAMB = 6 Then GoTo 103 'If NAMB = 7 Then GoTo 50 'GO TO (2, 3, 4, 5, 6, 103, 50),NAMB 2: FE(I) = F(I) WNE(I, 1) = EO(I) 'Write(6, 401) FE(I),WNE(I,1) GoTo 10 3: FE(I) = F(I) WNE(I, 1) = EO(I) + (G7(I) * EG(I)) 'Write(6, 401) FE(I),WNE(I,1) GoTo 10 4: FE(I) = F(I) / EO(I) WNE(I, 1) = EG(I) / EO(I) 'Write(6, 401) FE(I),WNE(I,1) GoTo 10 5: E(I) = EO(I) + EF(I) + (G7(I) * EG(I)) 'Write(6, 401) E(I) GoTo 120 6: E(I) = EO(I) + (G7(I) * EG(I)) FE(I) = F(I) / E(I) WNE(I, 1) = DP / E(I) 'Write(6, 401) E(I),FE(I),WNE(I,1) GoTo 10 103: CO = MGO SO = 1# - SWI F(I) = ANP(I) * BO(I) + WP(I) E(I) = BOO * DP / (1# - SWI) * (SO * CO + SWI * CW + CS) GoTo 120 '50: P2 = P(i) * P(i) ' DPP = 2.1999 * P(i) + 0.00026061 * P2 + 0.00000012598 * P2 * P(i) ' VT(i) = 1.+ DP / DPP ' BG(i) = 0.00235224 - 0.0000006793 * P(i) + 0.000000000070472 * P2 ' RP4(i) = GP4(i) * 1000./ ANP4(i) ' RP8(i) = GP8(i) * 1000./ ANP8(i) ' F(i) = ANP4(i) * (VT(i) * BTO4 + BG(i) * (RP4(i) - RSI4)) + ANP8(i) * (VT(i) * BTO8 + ' BG(i) * (RP8(i) - RSI8)) + WP(i) - WPI(i) ' E(i) = VT(i) * BTO1 - BTO1 + BTO1 / (1.- SWI) * (CS + CW * SWI) * DP + ' MGO * BTO1 / BGO * (BG(i) - BGO) 120: FE(I) = F(I) / E(I) T(I) = T1 + DT For J = 0 To M 'Do 11 J=1,M C1 = C(J) WNI(I, J) = INFLUX(K, DEP, TI, IR, B, C1, T(I)) WNE(I, J) = WNI(I, J) / E(I) Next J K = K + 1 If I = N - 1 Then GoTo 12 DEP(K) = P(I) - P(I + 1) 12: T1 = T1 + DT TI(K) = T(I) 10: Next I KII = N If L <= 0 Then GoTo 54 N = N - L For I = 0 To N T(I) = T(L + I) 56: FE(I) = FE(L + I) Next I For J = 0 To M 'Do 57 J=1,M For I = 0 To N WNE(I, J) = WNE(L + I, J) Next I Next J 54: For J = 0 To M If (MA - 1) < 0 Then GoTo 105 If (MA - 1) = 0 Then GoTo 108 If (MA - 1) > 0 Then GoTo 109 109: N = NA + LL For I = 0 To N 106: FE(I) = DE(I + LL, J) Next I GoTo 105 108: N = NA For I = 1 To N FE(I) = G(I + LL, J) / 1000000 '1.E + 6 59: WNE(I, J) = T(I + LL) Next I 105: For I = 0 To N XY(I) = WNE(I, J) * FE(I) 27: XKV(I) = WNE(I, J) ^ 2 Next I SY(1) = FE(1) SX(1) = WNE(1, J) SXY(1) = XY(1) SXKV(1) = XKV(1) For I = 1 To N

    SY(I) = SY(I - 1) + FE(I) SX(I) = SX(I - 1) + WNE(I, J) SXY(I) = SXY(I - 1) + XY(I) 21: SXKV(I) = SXKV(I - 1) + XKV(I) Next I For I = 0 To N 'Do 24 I=1,N A38 = SX(I) ^ 2 A39 = SXKV(I) * SY(I) A40 = SX(I) * SXY(I) A41 = A39 - A40 A43 = I * SXKV(I) A44 = A43 - A38 If A44 <= 0.00001 Then A44 = 0.00001 G(I, J) = A41 / A44 D(I) = (SY(I) - I * G(I, J)) / SX(I) SIGMA(I) = 0 If (I - N + 3) < 0 Then GoTo 31 If (I - N + 3) >= 0 Then GoTo 32 31: GoTo 24 32: SUMA = 0 For IV = 1 To I 'Do 33 IV=1,I Y(IV) = G(I, J) + D(I) * WNE(IV, J) SUMA = SUMA + (Y(IV) - FE(IV)) ^ 2 33: Next IV SIGMA(I) = Math.Sqrt(SUMA / I) 24: Next I '24 CONTINUE ' GO TO (301, 302, 303, 207, 305, 306),NAMB '301 WRITE(6,202) '201 FORMAT( //,11X,' LEZISTE NEMA VODENOG DOTOKA I NEMA GASNU KAPU '/ '1 //,5X,'VREDNOST Y=F',4X,'VREDNOST X=EO',4X,'OTSECAK=0.',6X, '1'NAGIB =REZERVE',9X,' ST.DEVIJAC.'/) ' GO TO 1111 '302 WRITE(6,202) '202 FORMAT( //,11X,' LEZISTE NEMA VODENOG DOTOKA ZNA SE GASNA KAPA '/ '1 //,5X,'VREDNOST Y=F',7X,'VREDNOST X',4X,'OTSECAK=0.',6X, '1'NAGIB =REZERVE',10X,' ST.DEVIJAC.'/) ' GO TO 1111 '303 WRITE(6,203) '203 FORMAT( //,11X,' LEZISTE NEMA VODENOG DOTOKA NEPOZNATE REZERVE I ' *GASNA KAPA '/ '1 //,2X,'VREDNOST Y=F/EO',2X,'VREDNOST X=EG/EO',2X,'OTSEC=REZER', '12X,'NAGIB=VEL.GAS.KAPE',10X,' ST DEVIJAC'/) ' GO TO 1111 '305 WRITE(6,205) '205 FORMAT( //,11X,' LEZISTE IMA MALI VODENI DOTOK,IMA ILI NEMA GASNU ' *KAPU '/ '1 //,2X,'VREDNOST Y=F/EO',2X,'VREDNOST X=DP/EO',2X,'OTSEC=REZER', '14X,'NAGIB=C',10X,'ST DEVIJAC '/) '1111 WRITE(6,210)(FE(I),WNE(I,J),G(I,J),D(I),SIGMA(I),I=1,N) '210 FORMAT(1H ,E20.5,E16.5,E17.5,E12.5,E23.5) ' GO TO 53 '306 WRITE(6,206) '206 FORMAT( //,11X,' LEZISTE JE IZNAD TACKE ZASICENJA I IMA VODENI ' *DOTOK ') ' GO TO 1164 '207 WRITE(6,1114) '1114 FORMAT( //,11X,'LEZISTE JE ISPOD TACKE ZASICENJA I IMA VODENI', ' *'DOTOK') '1164 WRITE(6,1113) C(J) '1113 FORMAT(/,'DELTA T=',F15.5) ' ++++++ If (MA - 1) Then Then61, 62, 163 '62 WRITE(6,63)(FE(I),WNE(I,J),G(I,J),D(I),SIGMA(I),I=1,N) '63 FORMAT(' ',6X,'REZERVE NAFTE',9X,'VREME',11X,'OTSECAK NAGIB-', '' *'TANG',13X,'STANDARDNA'/9X,'MET KUB',12X,'DANI',12X,'NA X-OSI', ' *6X,'ALFA',16X,'DEVIJACIJA'/80X,'MET KUB'//,60(E20.5,E16.5,E17.5, ' *E12.5,E23.5/' ')) ' GO TO 53 '163 WRITE(6,1163)(FE(I),WNE(I,J),G(I,J),D(I),SIGMA(I),I=1,N) '1163 FORMAT(' ',4X,'KONST. VOD. UTOKA',6X,'VREME',11X,'OTSECAK NAGIB ' *-','TANG',13X,'STANDARDNA'/9X,'MET KUB',12X,'DANI',12X,'NA X-OSI', ' *6X,'ALFA',16X,'DEVIJACIJA'/80X,'MET KUB'//,60(E20.5,E16.5,E17.5, ' *E12.5,E23.5/' ')) ' GO TO 53 ' 61 WRITE(6,52)(FE(I),WNI(I,J),WNE(I,J),G(I,J),D(I),SIGMA(I),I=1,N) '52 FORMAT(' '5X,'REZULTATI:' //,8X,' F/ET WN=SUMA(Q*DELTA ' 1P) WN/ET REZERVE NAFTE HURST-VAN',12X,'STANDARDNA'/73X,' ' 2EVERDINGENOVA',8X,'DEVIJACIJA'/73X,'KONSTANTA'//,9X,'(000 MET KU ' 3B)',20X,' (AT) (000 MET KUB) (000 MET KUB/DAN AT) (000 ME ' 4T KUB)'//,60(E20.5,2E16.5,E17.5,E12.5,E23.5/' ')) '1112 CONTINUE For I = 0 To N 'Do 107 I=1,N 107: DE(I, J) = D(I) Next I Next J '53 CONTINUE ' If (NAMB.LT.4.Or.NAMB.EQ.5) GO TO 102 ' If (KONT.EQ.1) GO TO 1021 MA = MA + 1 NA = N - LL If MA <= 2 Then GoTo 54 1021: N = KII ' GO TO 102 '111 STOP End Sub


    Thursday, July 5, 2018 9:23 AM

Answers