SOLIDWORKS Visual Basic for Applications

SOLIDWORKS Instructor Led Training

This basic to intermediate course covers the use of the SOLIDWORKS VBA ("built-in" Visual Basic for Applications) programming environment. In addition, this course provides you with introductory Visual Basic for Applications training to help familiarize you with the programming language.
You will be provided with many examples and working programs that can be used immediately in your work.

 

Course details and prerequisites:

Duration: 2 Days
Type: Instructor Led
Level: Basic to Intermediate

Prerequisites:

After the training you will be able to:
  • Create VBA modules and forms
  • Have a working understanding of syntax used in VBA for decision making and looping
  • Understand the concepts of modular programming

NOTE: this course is a prerequisite for the SOLIDWORKS API course.
Learn more about the SOLIDWORKS API course

 

Course Outline

Course topics include:

VBA Introduction

  • Around the room
  • Course Objectives
  • Prerequisites

Lesson 1 - Introduction to the VBA Development Environment

  • The Menu Bar and Toolbar
  • The Form Window
  • The Toolbox
  • The Project Explorer Window
  • The Properties Window
  • Help

Lesson 2 - Analyzing a Visual Basic Program

  • Event-Driven Programs
  • Control Events
  • Analyzing a Sample Application
  • Naming Objects
  • Running Applications
  • The Toolbox
  • The Code
  • Event Procedures
  • Properties and Event Procedures

Lesson 3 - Controls and Properties

  • Creating New Applications
  • Controls Provide the Interface
  • Placing Controls
  • Sizing and Moving Controls
  • Setting Properties
  • Giving Your Users Help
  • Named Literals
  • Creating an Application from Scratch

Lesson 4 - Labels, Buttons and Text Boxes

  • Control Focus
  • The Mouse and Hotkeys Need No Focus
  • Related Properties
  • Tab Order
  • Command Buttons
  • Labels             
  • Text Boxes
  • Form Properties

  Lesson 5 - Putting Code into Visual Basic

  • Coding Basics
  • Data Basics
  • Scientific Notation
  • Specifying Values
  • Variables Hold Data
  • The Dim Statements Location
  • Putting Data in Variables
  • Expressions and Math Operators

Lesson 6 - Making decisions with VBA

  • Comparison Operators
  • Keep Each Sides Data Type Consistent
  • The If Statement
  • The If Statements Else Branch
  • Compound Comparisons with the Logical Operators
  • Multiple Choice with Select Case
  • The Select Case Statement
  • Two More Select Case Formats

Lesson 7 - Looping with VBA

  • The Do While Loops
  • The Loops Termination
  • The Do Until Loop
  • Which Loop Is Best?
  • The Other Do Loops
  • The For Loop
  • Terminating Loops Early

Lesson 8 - Modular Programming

  • Structured Programming
  • Calling Procedures and Returning from Them
  • Why Code External Modules?
  • Coding Subroutines
  • Coding Functions
  • Coding Arguments
  • Receiving by Reference and by Value

Lesson 9 - Built-In Functions

  • Numeric Functions
  • String Functions
  • A Mid Statement?
  • Date and Time Functions
  • Data-Testing Functions
  • Data Conversion Functions
  • Format Function
  • You'll Rarely Need Format Codes

Lesson 10 - Debugging Techniques

  • Kinds of Errors
  • The Debugger
  • Setting Breakpoints
  • Stepping Through Code
  • The Call Stack Shows Where You’ve Been
  • The Immediate Window
  • Tips on Trouble Shooting