Help on using .ocx files 
Author Message
 Help on using .ocx files

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.



Mon, 29 Aug 2005 05:07:10 GMT  
 Help on using .ocx files
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.



Mon, 29 Aug 2005 20:18:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help on using an OCX file

2. OCX in an OCX -- Please Help

3. Using an .OCX file as a Public Function

4. Which OCX Files Are Used?

5. Using OCX files with Access ODE

6. Downloading a file using Mscomm32.ocx

7. I Need Help Using Rumba ObjectX Mainframe OCX

8. Creating Help Files for .OCX controls

9. .ocx files help?!

10. distribute ocx file - HELP


 
Powered by phpBB® Forum Software © phpBB Group