The following code is removed from its original context, so it may not look like anything useful, but it's enough for you to duplicate the error.
The VB module declare statements look like this:
Code:
Declare Sub DoSomething Lib "test.dll" () Declare Sub SetAddress Lib "test.dll" (ByRef ArrayAddress As Long)
Code:
Dim MyArray(10) As Long Private Sub Command1_Click() SetAddress MyArray(0) Call DoSomething End Sub
Code:
$Compile Dll "test.dll" Global MyArray() As Long Function LibMain(ByVal hInstance As Long, _ ByVal fwdReason As Long, _ ByVal lpvReserved As Long) Export As Long If fwdReason = 1 Then LibMain = 1 ReDim MyArray(10) As Long End If End Function Sub SetAddress Alias "SetAddress" (ByRef ArrayBase As Long) Export ReDim MyArray(10) As Long At ArrayBase ' The above line does not crash if I use Dim instead of ReDim End Sub Sub DoSomething Alias "DoSomething" Export MyArray(1) = 0 End Sub
As for pointers, they work great in the context in which they're used within in my component, but that does not negate the usefulness of being able to dim a variable at a location. For instance, I can't do "For @x = 1 To 10" since @x isn't considered a scalar variable. Although I don't have an immediate need for this in my current project, I think it can come in handy in other situatios.
------------------
Daniel Corbier
UCalc Fast Math Parser
http://www.ucalc.com
Leave a comment: