Debuging function in module?? 
Author Message
 Debuging function in module??

Spent a few hours with books, Help, and Microsoft Online Resource but can't
figure this one out!

Here's the code:

Private Function BestPriceCheck()
Dim curCost As Currency
Dim curLowestCost As Currency
Dim curDirectCost As Currency
Dim curLowestDirectCost As Currency
Dim strCurrentSupplier As String
Dim intPurchaseType As Integer
Rem Dim rstProductCost As Recordset
Rem Dim tdf As TableDefs
Rem Dim dbs As Database
Rem Dim fldCost As Field
Rem Dim fldDirectCost As Field
Rem Set dbs = CurrentDb
Rem Set tdf = dbs.TableDefs![Product Cost]

Rem Me.Description = Me.Product_ID.Column(1)
Rem curCost = Me.Cost
Rem If
curLowestCost = 12
Debug.Print curLowestCost
End Function

Quite obviously not complete..I'm still learning about rst and stuff but...I
wanted to test various values but couldn't get it right so I rem most things
and tried test for curLowestCost but I cant figure that out either.

I compile the module
I open the debug window and try some of the following in the Immediate Pane:

?BestPriceCheck()  which produces "Sub or Function Not defined" error
?BestPriceCheck  Which produces the cursor to drop down 2 lines but does not
return a value

I then changed the procedure to a sub and then did the same:

BestPriceCheck which produces "Expected procedure, not Variable" error

P.S. I don't understand the diference between a sub and a function since it
seems to me that you can return a value from either one?

Thanks for the help
Lee



Tue, 01 May 2001 03:00:00 GMT  
 Debuging function in module??

Quote:

>Spent a few hours with books, Help, and Microsoft Online Resource but can't
>figure this one out!
>....
>Quite obviously not complete..I'm still learning about rst and stuff
but...I
>wanted to test various values but couldn't get it right so I rem most
things
>and tried test for curLowestCost but I cant figure that out either.

>I compile the module
>I open the debug window and try some of the following in the Immediate
Pane:

>?BestPriceCheck()  which produces "Sub or Function Not defined" error
>?BestPriceCheck  Which produces the cursor to drop down 2 lines but does
not
>return a value

>I then changed the procedure to a sub and then did the same:

>BestPriceCheck which produces "Expected procedure, not Variable" error

>P.S. I don't understand the diference between a sub and a function since it
>seems to me that you can return a value from either one?

>Thanks for the help
>Lee

This module is attached to a form which is where the problem is.  I can get
the Debug.Print statement to work when I past the code into a module that is
not associate to any object and then only when I declare it public.

How do I do this when the module is associated with a form and when the
procedure is private?

Thanks again



Tue, 01 May 2001 03:00:00 GMT  
 Debuging function in module??
Lee,

Because you have declared BestPriceCheck as a *private* function, you need
to include its module name in a reference to it (outside of its own module).
The module name for a form module is the form name prepended with "Form_",
e.g. Form_MyForm. So you would need to use
  ? Form_MyForm.BestPriceCheck()
in the debug window.

Does that help?

Simon Lewis



Wed, 02 May 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Call module functions from outside of module?

2. Use of Excel functions in visual basic functions in excel module

3. Modules, Modules, Modules

4. config file disappears when debuging

5. Dispose and Finalize when debuging.

6. Debuging in ASP.Net

7. VBScript debuging in ASP files

8. Debuging Classes ????????

9. Running and debuging a complement (DLL ActiveX)

10. Problem Debuging DLL

11. Debuging a VB project with command line

12. Debuging VB components

 

 
Powered by phpBB® Forum Software