Can anyone help to figure out what is wrong here? Thanks a lot in advance.
This task is to call a DLL sub (PBWin 8.04 generated) for calculation outside Excel VBA. Then put the results on the worksheet.
'''PB DLL code '''''''''''''''''''''
''' file: hycUCC2.bas
#COMPILE DLL
SUB ABCD ALIAS "ABCD" (N as integer, A() as single, B() as single, C() as single) EXPORT
dim i as integer
for i=1 to N
C(i)=A(i) * B(i)
next i
END SUB
'''' Excel VBA code in Module'''''''''''''''
Public Declare Sub ABCD Lib "hycUCC2.dll" (K As Integer, AA() As Single, BB() As Single, CC() As Single)
''''' Excel code in worksheet VBA for command button ...
Private Sub CommandButton1_Click()
Dim a(4) As Single, b(4) As Single, c(4) As Single
For i = 1 To 4
a(i) = Cells(i + 2, 2).Value
b(i) = Cells(i + 2, 3).Value
Next i
Call ABCD(4, a(), b(), c())
For i = 1 To 4
Cells(i + 2, 5).Value = c(i)
Next i
End Sub
'''''''' Error message from Windows:
Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience.
This task is to call a DLL sub (PBWin 8.04 generated) for calculation outside Excel VBA. Then put the results on the worksheet.
'''PB DLL code '''''''''''''''''''''
''' file: hycUCC2.bas
#COMPILE DLL
SUB ABCD ALIAS "ABCD" (N as integer, A() as single, B() as single, C() as single) EXPORT
dim i as integer
for i=1 to N
C(i)=A(i) * B(i)
next i
END SUB
'''' Excel VBA code in Module'''''''''''''''
Public Declare Sub ABCD Lib "hycUCC2.dll" (K As Integer, AA() As Single, BB() As Single, CC() As Single)
''''' Excel code in worksheet VBA for command button ...
Private Sub CommandButton1_Click()
Dim a(4) As Single, b(4) As Single, c(4) As Single
For i = 1 To 4
a(i) = Cells(i + 2, 2).Value
b(i) = Cells(i + 2, 3).Value
Next i
Call ABCD(4, a(), b(), c())
For i = 1 To 4
Cells(i + 2, 5).Value = c(i)
Next i
End Sub
'''''''' Error message from Windows:
Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience.
Comment