research Question

Correct terminology for VBA Dim var As xxxxx.yyyyy. What is xxxxx and yyyyy?

Avatar of rberke
rberkeFlag for United States of America asked on
Microsoft OfficeVBA* Object Oriented Programming
13 Comments1 Solution30 ViewsLast Modified:
 
This is a question about the  terminology for “Dim var as  xxxxx.yyyyy “.  
 
For many years I loosely used terms like Library, Class, Type. But I am now trying to be more precise and find that I am confused.
For example: The following line defines an object with type Shellwindows from the ShDocVw Library,  
 
Dim var2 As New SHDocVw.ShellWindows
 
So it would appear that the general syntax is simple:
                Dim var As Library.Type
 
But I attach an image with a green circle that makes me wonder if the syntax is  
Dim var As Library.Class.
 
And eventually (but not now) I may ask a related question about CreateObject(class, [ servername ])
 
The image shows the following for Shellwindows.
 
 
    Class ShellWindows
    Member of SHDocVw     
    ShellDispatch Load in Shell Context
 
    Library SHDocVw
    C:\Windows\SysWOW64\ieframe.dll
    Microsoft Internet Controls
 
IN OTHER WORDS ShellWindows is a Class that is the member of the SHDocVw library which is from ieframe.dll

What it the correct terminology?
 
 
Microsoft documentation is not simple.  
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dim-statement syntax shows.  
 
Dim [ WithEvents ] varname [ ( [ subscripts ] ) ] [ As [ New ] type ] [ , [ WithEvents ] varname [ ( [ subscripts ] ) ] [ As [ New ] type ]] .
 
Where type is  Byte ,..etc… or an object type.
 
And Object type is: “A type of object exposed by an application through Automation, for example, Application, File, Range, and Sheet. Use the Object Browser or refer to the application's documentation for a complete listing of available objects.”
 
Clear as mud!
 
 
And here are several variable types that might be worth discussing
 
 
dim var0 as object
set var0 =  createobject ("Excel.Application")  ' vba help says syntax is CreateObject(class, [ servername ])
 
Dim var1 As New Scripting.Dictionary
Dim var2 As New SHDocVw.ShellWindows
Dim var3 As New Dao.Recordset
Dim var4 As New Scripting.FileSystemObject
Dim var5 As New Scripting.Folder
dim var6 As New Dataobject
dim var7 as New Excel.Application
 
 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros