Converter VB 6.0 code to VB.net

  • Thread starter Thread starter he9ap00
  • Start date Start date
H

he9ap00

Guest
I recently converted my dll files to VB.net. But when I did that I got two warnings. I am not sure on how to fix this error. Thanks for your help.

Visual Basic 6.0 Code
Visual Basic:
Public Function fnGetBottleRecall(spName As String, _
                iClinicID As Integer) As ADODB.Recordset
                
    On Error GoTo ErrorHandler
    
    Dim objRS As ADODB.Recordset
    Dim oData As New DBlock.CDataAMS
    Dim lngRetValue As Long
    Dim vArgs As Variant
    
    vArgs = Array(iClinicID)
    
    lngRetValue = oData.ReadData(objRS, spName, vArgs)
    
    Set fnGetBottleRecall = objRS
    
Proc_Exit:
    Exit Function
    
ErrorHandler:
    MsgBox Err.Description
    Resume Proc_Exit
    
End Function

VB.Net Code
Visual Basic:
	Public Function fnGetBottleRecall(ByRef spName As String, ByRef iClinicID As Short) As ADODB.Recordset
		
		On Error GoTo ErrorHandler
		
		Dim objRS As ADODB.Recordset
		Dim oData As New DBlock.CDataAMS
		Dim lngRetValue As Integer
		Dim vArgs As Object
		
		'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1041"'
		'UPGRADE_WARNING: Couldn't resolve default property of object vArgs. Click for more: 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1037"'
		vArgs = New Object(){iClinicID}
		
		lngRetValue = oData.ReadData(objRS, spName, vArgs)
		
		fnGetBottleRecall = objRS
		
Proc_Exit: 
		Exit Function
		
ErrorHandler: 
		MsgBox(Err.Description)
		Resume Proc_Exit
		
	End Function
End Class
 
I believe both those errors can be resolved by changing your
declaration of vArgs to:

Visual Basic:
Dim vArgs() As Object

And then you have to resize the array and stick your value in there:

Visual Basic:
' Put this in place of the errorous line:
ReDim vArgs(0) ' Resize the array

vArgs(0) = iClinicID ' Stick in the value

' rest of code goes here

HTH
 
Back
Top