G
Guest
I have migrated a software in Visual Basic 6.0 to Visual Basic .NET 200
I have solved the errors from compilation (AddressOf, ....) but when th
program is executed in the call to the DLL (loadnlp) I obtain an error. I
says the obj argument is not valid
Debuging I have checked the data used for the call to the DLL through Visua
Basil 6.0 and Visual Basic .Net are the same
I have tried everything, but I get the error again and again. Does anybod
know what can be the problem?
Thanks very muc
Regard
'Code in Visual Basic 6.
Declare Function loadnlp Lib "libreria.dll" (ByVal name As String, ByVal numcols As Long, ByVal numrows As Long, ByVal objsen As Long, obj() As Double, rhs() As Double, sense() As Byte, matbeg() As Long, matcnt() As Long, matind() As Long, matval() As Double, var() As Double, lb() As Double, ub() As Double, rngval() As Double, ByVal nzspace As Long, ByVal funceval As Long, ByVal jacobian As Long) As Lon
Public Sub VisualBasic60 (
Dim nNumVar As Intege
Dim nNumRest As Integer
Dim objval As Doubl
Dim ret,lp,nlstat As Lon
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
Dim ctype() As Byt
Dim NullL(0) As Lon
Dim NullD(0) As Doubl
Dim NullB(0) As Byt
nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1
NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0
end su
---------------------------
'Code in Visula Basic .NE
Delegate Sub SubClassProcDelegate(
Declare Function loadnlp Lib "libreria.dll" (ByVal probname As String, ByVal numcols As Integer, ByVal numrows As Integer, ByVal objsen As Integer, ByRef DatoObj() As Double, ByRef rhs() As Double, ByRef sense() As Byte, ByRef matbeg() As Integer, ByRef matcnt() As Integer, ByRef matind() As Integer, ByRef matval() As Double, ByRef var() As Double, ByRef lb() As Double, ByRef ub() As Double, ByRef rngval() As Double, ByVal nzspace As Integer, ByVal funceval As SubClassProcDelegate, ByVal jacobian As Integer) As Intege
Sub VisualBasic_NET (
Dim objval As Doubl
Dim ret, lp, nlstat As Intege
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
'UPGRADE_NOTE: ctype se actualizó a ctype_Renamed. Haga clic aquà para obtener más información: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"
Dim ctype_Renamed() As Byt
Dim NullL(0) As Intege
Dim NullD(0) As Doubl
Dim NullB(0) As Byt
nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1
NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0
end sub
I have solved the errors from compilation (AddressOf, ....) but when th
program is executed in the call to the DLL (loadnlp) I obtain an error. I
says the obj argument is not valid
Debuging I have checked the data used for the call to the DLL through Visua
Basil 6.0 and Visual Basic .Net are the same
I have tried everything, but I get the error again and again. Does anybod
know what can be the problem?
Thanks very muc
Regard
'Code in Visual Basic 6.
Declare Function loadnlp Lib "libreria.dll" (ByVal name As String, ByVal numcols As Long, ByVal numrows As Long, ByVal objsen As Long, obj() As Double, rhs() As Double, sense() As Byte, matbeg() As Long, matcnt() As Long, matind() As Long, matval() As Double, var() As Double, lb() As Double, ub() As Double, rngval() As Double, ByVal nzspace As Long, ByVal funceval As Long, ByVal jacobian As Long) As Lon
Public Sub VisualBasic60 (
Dim nNumVar As Intege
Dim nNumRest As Integer
Dim objval As Doubl
Dim ret,lp,nlstat As Lon
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
Dim ctype() As Byt
Dim NullL(0) As Lon
Dim NullD(0) As Doubl
Dim NullB(0) As Byt
nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1
NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0
end su
---------------------------
'Code in Visula Basic .NE
Delegate Sub SubClassProcDelegate(
Declare Function loadnlp Lib "libreria.dll" (ByVal probname As String, ByVal numcols As Integer, ByVal numrows As Integer, ByVal objsen As Integer, ByRef DatoObj() As Double, ByRef rhs() As Double, ByRef sense() As Byte, ByRef matbeg() As Integer, ByRef matcnt() As Integer, ByRef matind() As Integer, ByRef matval() As Double, ByRef var() As Double, ByRef lb() As Double, ByRef ub() As Double, ByRef rngval() As Double, ByVal nzspace As Integer, ByVal funceval As SubClassProcDelegate, ByVal jacobian As Integer) As Intege
Sub VisualBasic_NET (
Dim objval As Doubl
Dim ret, lp, nlstat As Intege
Dim obj() As Doubl
Dim rhs() As Doubl
Dim matval() As Doubl
Dim lb() As Doubl
Dim ub() As Doubl
Dim x() As Doubl
Dim piout() As Doubl
Dim slack() As Doubl
Dim dj() As Doubl
Dim sense() As Byt
'UPGRADE_NOTE: ctype se actualizó a ctype_Renamed. Haga clic aquà para obtener más información: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"
Dim ctype_Renamed() As Byt
Dim NullL(0) As Intege
Dim NullD(0) As Doubl
Dim NullB(0) As Byt
nNumVar =
ReDim obj(nNumVar - 1
ReDim lb(nNumVar - 1
ReDim ub(nNumVar - 1
ReDim ctype(nNumVar - 1
ReDim x(nNumVar - 1
ReDim dj(nNumVar - 1
NullL(0) = -
NullD(0) = -
NullB(0) =
nNumRest =
ReDim rhs(nNumRest - 1)
ReDim sense(nNumRest - 1
ReDim matval(nNumVar * nNumRest - 1
ReDim piout(nNumRest - 1
ReDim slack(nNumRest - 1
rhs(0) =
rhs(1) =
sense(0) = Asc("E"
sense(1) = Asc("E"
For nInd = 0 To (nNumVar) -
ctype(nInd) = Asc("C"
lb(nInd) =
ub(nInd) =
x(nInd) = 1 / (nNumVar
Nex
lp = loadnlp("123456", nNumVar, nNumRest, -1, obj, rhs, sense, NullL, NullL, NullL, matval, x, lb, ub, NullD, nNumVar * nNumRest, AddressOf metOptimo, 0
end sub