VbScript & VB

Results 1 to 2 of 2

Thread: VbScript & VB

  1. #1
    Join Date
    Dec 1969

    Default VbScript & VB

    When I test a function in my DLL (written in VB), everything OK. It returns me the correct records<BR>Then I change them to VBScript & add to my ASP page, it return 0 record. Why?<BR>Here&#039;s VB code to test the function <BR><BR>Private Sub cmdGetList_Click()<BR><BR>Dim objList As Employee.EmpSQL<BR>Dim strDept As String<BR>Dim strList As String<BR>Dim iCnt As Long<BR><BR>iCnt = 0<BR>strList = ""<BR>strDept = "HR"<BR>Set objList = CreateObject("Employee.EmpSQL")<BR>&#039;Note: GetList() function returns the number of record iCnt & employees&#039; name<BR><BR>objList.GetList strDept, iCnt, strList <BR>Debug.print "Rec Count = " & iCnt<BR><BR>end sub<BR>-------------------------------<BR>Here&#039;s code in ASP page:<BR><BR>&#060;%<BR>dim strName<BR>Dim objList <BR>Dim strDept<BR>Dim strList <BR>Dim iPtCnt<BR><BR>iCnt = 0<BR>strList = ""<BR>strDept = "HR"<BR>Set objList = Server.CreateObject("Employee.EmpSQL")<BR>objList. GetPtList Cstr(strDept), CLng(iPtCnt), CStr(strList)<BR>Response.Write "Rec Count = " & CLng(iPtCnt) <BR>%&#062; <BR>

  2. #2
    Join Date
    Dec 1969

    Default How can we tell?

    You don&#039;t show the code for the GetList() function, and it is surely the "culprit" here, no?<BR><BR>*****************<BR><BR>OH! I take it back!<BR><BR>I can see one problem right away!!!<BR><BR>You are passing an OUT parameter (iCnt in the VB, iPtCnt in the VBS) but you are doing CLNG() of it in the VBS code!<BR><BR>KABLOOEY! *ASSUMING* that&#039;s a ByRef argument in the GetPtList function, you can&#039;t do that! You&#039;ll be passing in the address of a temporary chunk of storage, because the call to CLNG() returns that as the result of its function call!<BR><BR>In any case, there is no reason at all to use CLNG.<BR><BR>*********************<BR><BR>ANOTHER BUG: You call the function "GetList" in the VB code but you call it "GetPtList" in the VBScript code. HUH?????<BR><BR>*********************<BR><BR>You probably also want to get rid of the BYREF arguments to all your VB functions. VBScript doesn&#039;t seem to handle BYREF very well.<BR><BR>Since you are creating an object there, just keep the count in a member variable and then invent another function to return its value, separately.<BR><BR>You can *TRY* having the iCnt argument be declared as<BR> ByRef iCnt AS Variant<BR>but I wouldn&#039;t count on even that working.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts