Visual Basic Programming. An Introduction



Similar documents
Athena Knowledge Base

X1 Professional Client

File Management With Windows Explorer

USC Marshall School of Business Marshall Information Services


Hypercosm. Studio.

Hands-On Lab. Client Workflow. Lab version: Last updated: 2/23/2011

SECURE USER GUIDE OUTLOOK 2000

QUICK START GUIDE. Draft twice the documents in half the time starting now.

Many applications consist of one or more classes, each containing one or more methods. If you become part of a development team in industry, you may

Content Author's Reference and Cookbook

How to Add Users 1. 2.

The VB development environment

Operating Systems. and Windows

RIT Installation Instructions

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

Chapter 11 Search December 2014 Page 1. Terms

VB.NET Programming Fundamentals

Visual Basic and Databases

TCP/IP Networking, Part 2: Web-Based Control

IFAS Reports. Participant s Manual. Version 1.0

Informatica e Sistemi in Tempo Reale

Adobe Acrobat: Creating Interactive Forms

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Dreamweaver Tutorials Creating a Web Contact Form

Introduction to MS WINDOWS XP

Designing and Implementing Forms 34

Subscription vs. RSS:

Programming in Access VBA

Contents. Introduction. Chapter 1 Some Hot Tips to Get You Started. Chapter 2 Tips on Working with Strings and Arrays..

Writer Guide. Chapter 10 Working with Templates

Mac Information. How to share files with Apple s MobileMe service

COMPUTER BASICS. Gordon Kelley Academic Success Center Vines Building, Room

Introduction to Microsoft Access 2003

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

Sample CSE8A midterm Multiple Choice (circle one)

SafeGuard PrivateCrypto 2.40 help

Applications Development

Introduction to Windows

Basic Computer Skills for Beginners. Mesa Regional Family History Center

Week 2 Practical Objects and Turtles

Word 2010: Mail Merge to with Attachments

Backing up with Windows 7

How to get MOSS 2007 dev. environment set up in Vista with sample project.

Chapter 4: Website Basics

Programming with the Dev C++ IDE

Printer Connection Manager

Google Drive: Access and organize your files

Creating Database Tables in Microsoft SQL Server

IBM FileNet eforms Designer

Source Code Translation

The C Programming Language course syllabus associate level


Web Ambassador Training on the CMS

PowerPoint 2013 Basics of Creating a PowerPoint Presentation

Table of Contents. Introduction: 2. Settings: 6. Archive 9. Search Browse Schedule Archiving: 18

INTRODUCTION to ESRI ARCGIS For Visualization, CPSC 178

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Windows Phone 7 Mobile Applications Using Decision Structures

USB CASH DRAWER INTERFACE. Introduction

KiCad Step by Step Tutorial

Capturing Webcam through VB6.0

INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB

QAD Business Intelligence Dashboards Demonstration Guide. May 2015 BI 3.11

Windows File Management A Hands-on Class Presented by Edith Einhorn

Changing the Display Frequency During Scanning Within an ImageControls 3 Application

SPSS: Getting Started. For Windows

My EA Builder 1.1 User Guide

Optional Lab: Schedule Task Using GUI and at Command in Windows 7

Double-click an appointment to view the details.

Creating a Participants Mailing and/or Contact List:

Exercise 1: Python Language Basics

ERserver. iseries. Work management

MS Access Lab 2. Topic: Tables

Database Automation using VBA

Scheduling Automated Outlet Control Using FineSNMPSet with Sentry Switched Power Distribution Units

Visual Basic 2010 Essentials

EWF Management Software Windows driver software for Classembly Devices /Industrial Controller

Making a Web Page with Microsoft Publisher 2003

Introduction to Computer and Information Science CIS 110, Fall 2015

The FTS Real Time System lets you create algorithmic trading strategies, as follows:

1. Open Thunderbird. If the Import Wizard window opens, select Don t import anything and click Next and go to step 3.

Using the Remote Access Library

Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11

A SharePoint Developer Introduction

Excel & Visual Basic for Applications (VBA)

Form Validation. Server-side Web Development and Programming. What to Validate. Error Prevention. Lecture 7: Input Validation and Error Handling

SMART Board Training Outline Trainer: Basel Badran

Using the ecommerce Features in Drupal 6.0

The LSUHSC N.O. Archive

How To Write A Macro In Libreoffice (Free) With Libre Office And Libreos With A Microspat

Understand for FORTRAN

9608/9611 IP Phone User Guide

2 SQL in iseries Navigator

Introduction. Syntax Statements. Colon : Line Continuation _ Conditions. If Then Else End If 1. block form syntax 2. One-Line syntax. Do...

MICROSOFT ACCESS 2003 TUTORIAL

DECS DER APPLE WIRELESS HELPER DOCUMENT

Solutions from SAP. SAP Business One 2005 SP01. User Interface. Standards and Guidelines. January 2006

Perceptive Intelligent Capture Solution Configration Manager

FAQ CE 5.0 and WM 5.0 Application Development

Transcription:

Visual Basic Programming An Introduction

Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides a convenient method for building user interfaces. Visual Basic can interface with code written in C, for efficiency.

What Visual Basic is not Visual Basic is not, a powerful programming language that enables you to do anything you want. Visual Basic is not, elegant or fast. Visual Basic is not, a replacement for C. Visual Basic is not, anything like any other programming language you have ever used.

When You Program in VB: You draw pictures of your user interface. You draw buttons, text boxes, and other user-interface items. You add little snippets of code to handle the user interaction. You add initialization code, usually as the last step. If you like, you can code more complex functions. (But many do not.)

The Visual Basic Interface Draw Your Program Here!

Drawing The Program Select A Control From Here (Click on the appropriate button) Then Draw the control on the form

Types of Controls Static Text Group Box Check Box Scroll Bar Drop-Down List Timer Folder Hierarchy Circles and Stuff Pictures Pictures Editable Text Button Radio Button List Scroll Bar Drive List File List Lines Data Base Access And the List Goes On and On...

A Simple Program Double-Click to Add Code Single-Click to Select and Change Properties Using controls: Static Text Editable Text Buttons

The Properties Window List of Properties For Currently Selected Control Click on Property, and Type In New Value, or Select New Value From Menu.

Adding Code Control Name External Event Name You must Write The Body Yourself What to Do When It Happens

More Complex Controls Complex Controls Have: Action Properties to Execute Commands Active Properties that Cause Actions When Values Are Assigned to Them Many Types of Events for Program Interaction Examples: Spreadsheets Word Processors Web Browsers

Using C Code Write a DLL in C Use the _export Property on Appropriate Functions Write Visual Basic Definitions for each Function Add VB Definitions to The (general) section of the VB Program Use Functions as if they were VB functions

C Definition vs. VB Definition C: long FAR PASCAL _export HexToLong (char *Hex) VB: Declare Function HexToLong Lib FIRSTONE.DLL (ByVal InString As String) As Long Function Name Must Be The Same in Both Declarations. The Lib keyword Must Give The Name of the Library. Argument Name in VB is arbitrary.

A (Very Annoying) Problem It is sometimes difficult for VB to FIND the.dll file. If this occurs, copy the.dll file to the WINDOWS directory. Remember to Delete the file when you are done.

Alternative Methods Some Versions of VB do not allow DLL function definitions in the (general) section of a form. To Get Around this Problem, Create a new Module (File Menu) Add the declarations to the (general) section of the module You can add your own VB functions to the (general) section of a form or a module.

Syntax Considerations All Functions are Global in VB Variables are declared using the syntax: Dim <Name> As <Type> Every variable must have a type Dim A,B,C As <Type> will work, but gives weird results Most Common Types: Integer, String, Long

More VB Syntax Use Integers for Booleans As in C, 0 = False, everything else = True Symbolic constants True and False may be used True = -1, False = 0 Assignments are the same as in C The Val function converts strings to integers The Format$ function converts integers to strings

VB Statements Assignments are the Same as in C Case is not significant Case will be adjusted for you on keywords For Variable Names, Case is ignored The Usual Operators can be used AND is the same as both & and && depending on context OR = and NOT =!

VB IF Statements If <condition> Then <List of Statements> Else <List of Statements> EndIf If <condition> Then <List of Statements> EndIf Comparators: =,<, >, <=, >=, < > (not equal) Connectives: And, Or, Not DON T FORGET THE ENDIF!

VB While Statements While <condition> do <List of Statements> Wend The VB Manual Recommends a different structure. Use the alternative if you wish.

VB For Statements For <Variable> = <start> to <finish> <List of Statements> Next <Variable> For <Variable> = <start> to <finish> Step <increment> <List of Statements> Next <Variable> Example: For I = 1 to 10 do A[I] = A[I] + 1 Next I

VB Arrays Indices Always Start With Zero Dim A[10] As Integer Declares 11 elements, indexed from 0 through 10. Multi-Dimensional Arrays are Permitted. Arrays can be resized at run time (See VB Help File for ReDim)

VB Strings Variable Length Compare using standard comparators Maximum length is about 64Kb Minimum length is zero Allocated from VB String Space, so may run out of space even on systems with much memory.

And in Conclusion... Go Have Fun!

Visual Basic Programming An Introduction

Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides a convenient method for building user interfaces. Visual Basic can interface with code written in C, for efficiency.

What Visual Basic is not Visual Basic is not, a powerful programming language that enables you to do anything you want. Visual Basic is not, elegant or fast. Visual Basic is not, a replacement for C. Visual Basic is not, anything like any other programming language you have ever used.

When You Program in VB: You draw pictures of your user interface. You draw buttons, text boxes, and other user-interface items. You add little snippets of code to handle the user interaction. You add initialization code, usually as the last step. If you like, you can code more complex functions. (But many do not.)

The Visual Basic Interface Draw Your Program Here!

Drawing The Program Select A Control From Here (Click on the appropriate button) Then Draw the control on the form

Types of Controls Static Text Group Box Check Box Scroll Bar Drop-Down List Timer Folder Hierarchy Circles and Stuff Pictures Pictures Editable Text Button Radio Button List Scroll Bar Drive List File List Lines Data Base Access And the List Goes On and On...

A Simple Program Double-Click to Add Code Single-Click to Select and Change Properties Using controls: Static Text Editable Text Buttons

The Properties Window List of Properties For Currently Selected Control Click on Property, and Type In New Value, or Select New Value From Menu.

Adding Code Control Name External Event Name You must Write The Body Yourself What to Do When It Happens

More Complex Controls Complex Controls Have: Action Properties to Execute Commands Active Properties that Cause Actions When Values Are Assigned to Them Many Types of Events for Program Interaction Examples: Spreadsheets Word Processors Web Browsers

Using C Code Write a DLL in C Use the _export Property on Appropriate Functions Write Visual Basic Definitions for each Function Add VB Definitions to The (general) section of the VB Program Use Functions as if they were VB functions

C Definition vs. VB Definition C: long FAR PASCAL _export HexToLong (char *Hex) VB: Declare Function HexToLong Lib FIRSTONE.DLL (ByVal InString As String) As Long Function Name Must Be The Same in Both Declarations. The Lib keyword Must Give The Name of the Library. Argument Name in VB is arbitrary.

A (Very Annoying) Problem It is sometimes difficult for VB to FIND the.dll file. If this occurs, copy the.dll file to the WINDOWS directory. Remember to Delete the file when you are done.

Alternative Methods Some Versions of VB do not allow DLL function definitions in the (general) section of a form. To Get Around this Problem, Create a new Module (File Menu) Add the declarations to the (general) section of the module You can add your own VB functions to the (general) section of a form or a module.

Syntax Considerations All Functions are Global in VB Variables are declared using the syntax: Dim <Name> As <Type> Every variable must have a type Dim A,B,C As <Type> will work, but gives weird results Most Common Types: Integer, String, Long

More VB Syntax Use Integers for Booleans As in C, 0 = False, everything else = True Symbolic constants True and False may be used True = -1, False = 0 Assignments are the same as in C The Val function converts strings to integers The Format$ function converts integers to strings

VB Statements Assignments are the Same as in C Case is not significant Case will be adjusted for you on keywords For Variable Names, Case is ignored The Usual Operators can be used AND is the same as both & and && depending on context OR = and NOT =!

VB IF Statements If <condition> Then <List of Statements> Else <List of Statements> EndIf If <condition> Then <List of Statements> EndIf Comparators: =,<, >, <=, >=, < > (not equal) Connectives: And, Or, Not DON T FORGET THE ENDIF!

VB While Statements While <condition> do <List of Statements> Wend The VB Manual Recommends a different structure. Use the alternative if you wish.

VB For Statements For <Variable> = <start> to <finish> <List of Statements> Next <Variable> For <Variable> = <start> to <finish> Step <increment> <List of Statements> Next <Variable> Example: For I = 1 to 10 do A[I] = A[I] + 1 Next I

VB Arrays Indices Always Start With Zero Dim A[10] As Integer Declares 11 elements, indexed from 0 through 10. Multi-Dimensional Arrays are Permitted. Arrays can be resized at run time (See VB Help File for ReDim)

VB Strings Variable Length Compare using standard comparators Maximum length is about 64Kb Minimum length is zero Allocated from VB String Space, so may run out of space even on systems with much memory.

And in Conclusion... Go Have Fun!