DLL & WritePrivateProfileString Questions 
Author Message
 DLL & WritePrivateProfileString Questions

I have been putting together an ActiveX DLL that includes three Class
modules.  One Class has all the properties, functions and subs used to Read
and Write Data to the Win and Private INI APIs.  The other two comprise the
collection that I generate in order to interface to the Get and Save Section
APIs.

This DLL compiles fine, and after registering it in Win NT 4.0 and adding
the Reference to the VB 5.0 project, I can make use of it in my project like
so ...

Dim MyObject as Object
Set MyObject = CreateObject("ClassName.DllName")

Now, when I go to use MyObject, I do not get the pop-up selection box for
the properties, methods or arguments.  If I manually type in the property or
method names, it does recognise them.  I can tell because (A) it corrects
the capitalization of the keyword when I hit enter and (B) the method
functions and property Get/Set routines work fine.  Anyone know what I have
to do to get it to prompt the user with the properties, methods and
arguments?  Besides making it an OCX ... I prefer not to do that.

On a related question, I found that when I used the
WritePrivateProfileString API that the declare statement defines the
argument containing the value to be written to the file as type 'Any'.  Now,
my understanding was that I could put any variable type into that argument
and it would work fine.  However, when I tried to call that function with a
'Variant' for that parameter, it choked.  I had to convert my Variant to a
String to make the function work.  Any idea why this is?

--

Tony Selke

(please remove the _No-Junk-Mail_ prior to responding)

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\



Wed, 13 Sep 2000 03:00:00 GMT  
 DLL & WritePrivateProfileString Questions



<cut>

Quote:

> Dim MyObject as Object
> Set MyObject = CreateObject("ClassName.DllName")

> Now, when I go to use MyObject, I do not get the pop-up selection box for
> the properties, methods or arguments.  If I manually type in the property
or
> method names, it does recognise them.  I can tell because (A) it corrects
> the capitalization of the keyword when I hit enter and (B) the method
> functions and property Get/Set routines work fine.  Anyone know what I
have
> to do to get it to prompt the user with the properties, methods and
> arguments?  Besides making it an OCX ... I prefer not to do that.

Because you defined it "As Object" the VB IDE can not know what kind of
object it is.  This is called "late binding" and is slower than "early
binding" where you specify the type explicitly at design time.  try:
Dim MyObject As ClassName.DllName
Set MyObject = New ClassName.DllName ' CreateObject should still work

Quote:
> On a related question, I found that when I used the
> WritePrivateProfileString API that the declare statement defines the
> argument containing the value to be written to the file as type 'Any'.
Now,
> my understanding was that I could put any variable type into that
argument
> and it would work fine.  However, when I tried to call that function with
a
> 'Variant' for that parameter, it choked.  I had to convert my Variant to
a
> String to make the function work.  Any idea why this is?

VB is having a hard time figuring out how to represent the data because the
call doesn't specify what it wants.  (ByRef? ByVal? data type?)  The
purpose of the "As Any" is mostly so you can call it passing "ByVal 0&" to
pass a null pointer in earlier versions of VB.  Passing a null pointer lets
you read/delete entire sections of the INI file depending on what
parameters you use it on.  With VB5 you can use the vbNullString constant
to pass a null pointer to an argument defined "As String" so you should
probably make the Declare specific and use vbNullString to call it.  If you
really want to use the variant, try making it a specific type as in
"CLng(myvariant)" or "ByVal Clng(myvariant)" depending on what you need to
do.


Wed, 13 Sep 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DLL & WritePrivateProfileString Questions

2. *&*&*&* Date math question *&*&*&*

3. VB4 (16bit) & WritePrivateProfileString

4. VB4 (16) & WritePrivateProfileString

5. DLL Question & Source Code question

6. WritePrivateProfileString API question

7. Writeprivateprofilestring question

8. WritePrivateProfileString Question

9. Question: .DLL search path & ActiveX/COM components

10. OCX & DLL question

11. QUESTION] MSVB 3.0 & DLL's

12. Setup Wizard & ddeml.dll question

 

 
Powered by phpBB® Forum Software