A blog on Tally Integration, to import and export data from Tally.ERP programmatically using VB6, VB.NET,C#,ASP.NET etc

Tuesday, June 5, 2007

A common mistake in VB

One common problem faced by many programmers while using DLL functions in Visual Basic is NOT specifying the ByVal for String Parameters.

Correct Declaration
Declare Function SQLRequest Lib "RTSLINK.DLL" (ByVal strSQL As String) As Long

Incorrect Declaration
Declare Function SQLRequest Lib "RTSLINK.DLL" (strSQL As String) As Long

Remarks:-
By default, parameters are passed by Reference in Visual Basic. If you need to pass the parameter ByVal, it has to be explicitly specified using the ByVal keyword.

Please note that the String parameters are to be always passed ByVal to DLL functions.

No comments: