12114:demo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
12114:demo [2024/04/15 04:05 UTC] – [Download and Save Sample Code] mwolfe12114:demo [2024/04/15 19:11 UTC] (current) – [Demo Script: DevCon 2024] mike
Line 1: Line 1:
 ====== Demo Script: DevCon 2024 ====== ====== Demo Script: DevCon 2024 ======
  
 +  * I have 25 minutes for the demo portion:
 +    * 0:01: Download and open twinBASIC
 +    * 0:02: Customize add-in name and description
 +    * 0:04: Create the tool window controls
 +    * 0:05: Edit the Code in myToolWindow
 +    * 0:07: Test in Access
 +    * 0:10: Explain Strongly-typed collections and copy ''BuildStronglyTypedCollection()'' function
 +    * 0:15: Bring in other dependencies
 +    * 0:16: Test in Access
 +    * 0:18: Test in Barebones Access
 +    * 0:22: Convert fafalone's WinDevLib package
 +    * 0:24: Build 64-bit version
 +    * 0:25: Explain ''regsvr32'' registration; mention InnoSetup
 ===== Download and Save Sample Code ===== ===== Download and Save Sample Code =====
  
Line 6: Line 19:
   - Extract from Zip folder   - Extract from Zip folder
   - Open twinBASIC > **Sample 4**   - Open twinBASIC > **Sample 4**
-  - Enter Project Name: ''Demo 2024'' (//Leave all other options at their defaults//)+  - Enter Project Name: ''Demo2024'' (//Do not put spaces in the name//)
   - Save as: ''%tmp%\Demo2024\Demo2024.twinproj''   - Save as: ''%tmp%\Demo2024\Demo2024.twinproj''
     - Navigate to: ''%tmp%''     - Navigate to: ''%tmp%''
     - Create folder named: ''Demo2024''     - Create folder named: ''Demo2024''
     - Filename: ''Demo2024.twinproj''     - Filename: ''Demo2024.twinproj''
 +
 +===== Customize the Addin Name and Description =====
 +Next, let's customize the friendly name and description of our addin.  This is the info that appears in the VBA Add-in Manager dialog box.
 +  - Go to **dllRegistration.twin** > **DllRegisterServer**
 +  - In the "FriendlyName" line, replace //AddinProjectName// with ''"DevCon 2024 Demo"''
 +  - In the "Description" line, replace //AddinProjectName// with ''"Create a strongly-typed collection class from an existing VBA class object."''
 +  - Save the project
 +  - Build the project
 +  - Launch ''M:\Repos\NLS\DevCon2024\DevCon2024.accdb''
 +  - Switch to VBA: <key>Ctrl</key> + <key>G</key>
 +  - Dock the add-in window
 +  - Go to "Add-Ins" > "Toggle myToolWindow Visibility"
 +  - Go to "Add-Ins" > "Add-in Manager"
 +    * Point out the "DevCon 2024 Demo" item with description below
 +  - Close "Add-In Manager" window 
  
 ===== Create the Tool Window Controls ===== ===== Create the Tool Window Controls =====
 +Next, we're going to customize the controls that appear on the tool window.  I'll explain what these controls will be used for in a minute.  For now, all you need to know is that we are adding two text boxes, a command button, and a label to hold a version number.
  
   - Open myToolWindow.tbcontrol   - Open myToolWindow.tbcontrol
   - Select all controls and delete them   - Select all controls and delete them
 +  - Click DIAGNOSTICS error to go to myToolWindow.twin and **delete all dead code**
   - Select form and set the following properties:   - Select form and set the following properties:
     * Height: 1700     * Height: 1700
Line 45: Line 75:
     * Top: 1050     * Top: 1050
     * Width: 2250        * Width: 2250   
 +  - Create a version label
 +    * Caption: Version {hhmm}  
  
 ===== Edit the Code in myToolWindow.twin ===== ===== Edit the Code in myToolWindow.twin =====
Line 58: Line 90:
 </code> </code>
  
-===== Build and Test the Addin on Same Machine ===== +===== Test the Updated Addin ===== 
-The following instructions assume a machine with 32-bit Office (e.g., mjw20):+ 
 +  - Make sure Access is closed then **Build** the tB project 
 +  - Reopen Access and switch to VBA 
 +  - Enter sample text ''oVehicle'' for object class name and ''collVehicles'' for collection class name then click [Create Collection Class] 
 +  
 +===== Strongly-Typed Collection Class ===== 
 +Now, let's talk about what this add-in will actually, you know, //do//. 
 + 
 +The purpose of the add-in is to encapsulate the ''BuildStronglyTypedCollection()'' function as described here: [[https://nolongerset.com/strongly-typed-collection-classes-the-easy-way/|Strongly-Typed Collections: The Easy Way]] 
 + 
 +I put a link to this article in the Resources page for today's presentation If you've never heard of strongly-typed collection classesI recommend you read up on them later. 
 + 
 +For our purposes, the important thing to know about them is that you CANNOT build them in the VBA editor.  They require setting a couple of hidden code attributes that only appear when you export the code module to a text file. 
 + 
 +As you can imagine, manually jumping through those hoops is inefficient and error-prone.  The existing code I wrote in VBA does automate the process, but it requires importing several additional dependencies.  Our VBE add-in will be a direct replacement for the ''BuildStronglyTypedCollection()'' function. 
 + 
 +===== Copy the VBA Code Into twinBASIC =====
  
-  - Ensure "**win32**" is selected in dropdown +  - Create a new module named MyModule.twin 
-  - **File** > **Build** +  - 
-    * Creates and registers this file: ''M:\Repos\NLS\DevCon2024\Build\DevCon2024_win32.dll'' +
-    * As part of registration, the following registry key and values are created: +
-      * ''HKEY_CURRENT_USER\SOFTWARE\Microsoft\VBA\VBE\6.0\Addins\DevCon2024.myAddIn\'' +
-        * Description: "DevCon2024" +
-        * FriendlyName: "DevCon2024" +
-        * LoadBehavior: 3  ([[https://learn.microsoft.com/en-us/visualstudio/vsto/registry-entries-for-vsto-add-ins?view=vs-2022#LoadBehavior|3 => Loaded/Load at startup]]) +
-      * ''HKEY_CLASSES_ROOT\DevCon2024.myAddIn\CLSID'' +
-        * (Default): ''{9B80DA6E-8B20-4D53-AE54-430ACFAE987B}''  //(this matches the ''[ClassID()]'' attribute value above the myAddIn class in myAddIn.twin)//\\ {{:gb:fb:pasted:20240410-034733.png}} +
-      * ''HKEY_CLASSES_ROOT\DevCon2024.myToolWindow\CLSID'' +
-        * (Default): ''{D531346A-90B8-470D-AA33-FB009F19CEFD}''  //(this matches the ''[ClassID()]'' attribute value above the myToolWindow class in myToolWindow.twin)//\\ {{:gb:fb:pasted:20240410-034605.png}} +
-      * ''HKEY_CLASSES_ROOT\CLSID\{9B80DA6E-8B20-4D53-AE54-430ACFAE987B}'' +
-        * (Default): ''myAddIn'' +
-        * ''\InProcServer32'' +
-          * (Default): ''M:\Repos\NLS\DevCon2024\Build\DevCon2024_win64.dll''  //(<wrap important>NOTE</wrap>: The presence of win64.dll here is likely a result of running the win64 build as shown in the next section)// +
-          * ThreadingModel: Both +
-        * ''\ProgID'' +
-          * (Default): ''DevCon2024.myAddIn''\\ {{:gb:fb:pasted:20240410-035346.png}} +
-    * DEBUG CONSOLE should show this:  +
-      * [LINKER] SUCCESS created output file 'M:\Repos\NLS\DevCon2024\Build\DevCon2024_win32.dll' +
-      * [LINKER]    -> Open Folder //(NOTE: this is a clickable link)// +
-      * [REGISTER] type-library registration completed. DllRegisterServer() returned OK +
-  - Open Excel or Access +
-  - Press [Alt] + [F11] to go to VBA IDE +
-  - Tool window will likely be floating; click and drag to dock it somewhere:\\ {{:gb:fb:pasted:20240410-032600.png}} +
-  - Enter ''Obj Name'' in the first text box, ''Coll Name'' in the second text box, then click [Create Collection Class]\\ {{:gb:fb:pasted:20240410-032714.png}}+
  
 ===== Build and Test the Addin on a Different Machine and Bitness ===== ===== Build and Test the Addin on a Different Machine and Bitness =====
  • 12114/demo.1713153947.txt.gz
  • Last modified: 2024/04/15 04:05 UTC
  • by mwolfe