you can't create an instance using New for this class.
You can use it on a form though.
If you don't particularly want a visual system, plonk the control on a form,
create your subs and functions on the form as public.
Instance the new form using the New keyword.
Set frmk = New Form_Form1
...where Form_Form1 is replaced with the **class** name of your form.
...you can then use property lets and gets to wrap the control access or
just declare the type public and assign it at load time.
Now you have a form with the control available...
Option Compare Database
Option Explicit
Public Converter As HijriCalendar.Calendar
Private Sub Form_Load()
Set Converter = ctrlCalendar.object '(the instance of the control on the
form)
End Sub
from this point on, to get at the functionality of the control in to ways
the variable or the 'native' variable(property or control) ...
Forms!FormName!ctrlCalendar.ToHijri(strDate)
or
Forms!FormName.Converter.ToHijri(strDate)
or You can plop your function onto the form and reference the control...
Public Function ConvertGregorian( strDate As string) As string
Dim Converter As HijriCalendar.Calendar
' you can dim it here or public...whatever
Set Converter = ctrlCalendar.object '(the instance of the control on the
form)
ConvertGregorian = Converter.ToHijri(strDate)
End Function
you use this by ...
answer = Forms!FormName.ConvertGregorian("somedate)
..all this depends on the controls properties (functions (let / get pairs)
and methods.
Some classes (controls) such as the common control listview *can* be created
'off form' in a module. Most can't though
hth
--
peter walker MVP
Quote:
> Hello;
> I have downloaded a zipped file named HijriCalendar.ocx that converts a
> usual Gregorian date to a especial type of Hijri date(Not supported by
> Access XP),and added a reference to it.When i saw it in Object Browser,It
> had just one class named Calendar,and some properties,events and methods
in
> it.One of this methods is 'ToHijri' that takes 'strDate as string' , as
its
> argument.Now my problem is to how to use it.I typed these lines in a
> Standard Module,(Thanx to the SteveT,a groupmate who helped me):
> Public Function ConvertGregorian( strDate As string) As string
> Dim Converter As HijriCalendar.Calendar
> Set Converter = New HijriCalendar.Calendar
> ConvertGregorian = Converter.ToHijri(strDate)
> Set Converter = Nothing
> End Function
> But it still doesnt work.The occured error is "Invalid use of New
> Keyword".May be the ocx file is not instanciatable,but im not sure.What is
> wrong?How to apply and use its Events and Properties?
> Any solution?
> Thank you so much in advance for ur help.