Senin, 22 Maret 2021

Re: [MSAccessProfessionals] Going through Book.

You use Access at Purdue?

Giorgio

On 03/22/2021 8:54 PM jebryme <bridgham@purdue.edu> wrote:


Hi Bill!

 

The basic difference between a function and a sub is the function returns data. In your example it will return a string. You want to use functions when you plan to use the data without storing it in the underlying data for example you can use a function as a field in a query to manipulate the data. A sub on the other hand returns no data and is often used to edit records or add records in the data.

 

Jeff

 

 

From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> On Behalf Of Bill Singer
Sent: Monday, March 22, 2021 3:37 PM
To: MSAccessProfessionals@groups.io
Subject: [MSAccessProfessionals] Going through Book.


Can someone help me to understand this.


I am going through the book Access 2010 VBA programming Inside Out and I come across to ways to do the same thing  (I believe).


I am trying to understand the difference between FUNCTIONS  and SUB ROUTINES and whey the first statement is different (and when to use each).


Here is the Sub example.

Sub modIF_IF_Simple(Rating As Long)


Here is the Function Example

Function modIF_IF1(Rating As Long) As String


What is the difference and why is the "As String" needed at the in the function and not the sub.


Thanks,

Rookie,

Bill Singer

Minnesota

Access 365


Tidak ada komentar:

Posting Komentar