From: Tim Jacob on
Is it possible to create a function library (as opposed to a class
library)? And how to you access the functions in the library?

For example, I would like to be able to call an external function that
does some sort of conversion process such as below:

Function Monday(ByVal dDay As DateTime) As Date
Return dDay.Date.AddDays(-dDay.DayOfWeek + 1)
End Function

I would pass a DateTime variable to it, and it would return the Monday
of that week.

So how do I make this available to my application(s) without having to
put it in each module?

Thanks
From: Tim Jacob on
On 3/26/2010 10:14 AM, Tim Jacob wrote:
> Is it possible to create a function library (as opposed to a class
> library)? And how to you access the functions in the library?
>
> For example, I would like to be able to call an external function that
> does some sort of conversion process such as below:
>
> Function Monday(ByVal dDay As DateTime) As Date
> Return dDay.Date.AddDays(-dDay.DayOfWeek + 1)
> End Function
>
> I would pass a DateTime variable to it, and it would return the Monday
> of that week.
>
> So how do I make this available to my application(s) without having to
> put it in each module?
>
> Thanks

Found it. I had the functions in a Module, but had to declare the
module as "Public Module"
From: Herfried K. Wagner [MVP] on
Tim --

Am 26.03.2010 15:01, schrieb Tim Jacob:
>> Is it possible to create a function library (as opposed to a class
>> library)? And how to you access the functions in the library?
>>
>> For example, I would like to be able to call an external function that
>> does some sort of conversion process such as below:
>>
>> Function Monday(ByVal dDay As DateTime) As Date
>> Return dDay.Date.AddDays(-dDay.DayOfWeek + 1)
>> End Function
>>
>> I would pass a DateTime variable to it, and it would return the Monday
>> of that week.
>>
>> So how do I make this available to my application(s) without having to
>> put it in each module?
>>
>> Thanks
>
> Found it. I had the functions in a Module, but had to declare the module
> as "Public Module"

That should work. If you have a lot of functions, you may want to add
them to a class as shared members, similar to the 'Math' class. This
will prevent VB from automatically importing the functions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>