Adding Code to the Option Button. Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

Working with Intrinsic Controls and ActiveX Controls
Ch. 3 Variables VB.Net Programming. Data Types Boolean – True or False values Short – Small integers (+/- 32,767) Integer – Medium-size integers (+/-
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Flowchart Start Input weight and height
Text Box controls are used when users are required to type some input (during program execution), or output is displayed on the form (known as the user-
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
OF COURSE I DON'T LOOK BUSY... I DID IT RIGHT THE FIRST TIME
Muffin Shop - if, calculations etc. (muffins, muffins2) Please use speaker notes for additional information!
MS-Access XP Lesson 5. Creating a Query with Expression Builder Eg. Consider the following table. Table Name: Overtime Fields & Data types: Emp No (Number),
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
CS0004: Introduction to Programming Input and Output.
Adapting a ready made PowerPoint quiz with VBA
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
Remote Instruction: Teaching with Visual Basic EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume.
New Project in Visual Basic Please use speaker notes for additional information!
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Tutorial 6 The Repetition Structure
VPL basic – data and variables Young Joon Kim MSRDS First Beginner Course – STEP6.
Arrays. Overview u General Discussion  Uses  Structure  Declaration u Searching u Control Arrays.
University of Sunderland CIF 104 Fundamentals of DatabasesUnit 16 SESSION 16 VBA example.
Arrays1 From time to time an object (a variable, a picture, a label or a command) does not serve as well as a set of objects of a similar kind addressed.
A Simple Guide to Using SPSS ( Statistical Package for the Social Sciences) for Windows.
Class 3 Remote Instruction Computer Math EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume is.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
1 Advanced Computer Programming Lab Calculator Project.
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 2 More Controls.
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
VAT Calculator program Controls Properties Code Results.
Pay Example (PFirst98) Please use speaker notes for additional information!
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Lesson 4 Mathematical Operators! October 6, 2009.
31/01/ Selection If selection construct.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
Controlling Program Flow with Looping Structures
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Skyward and Epsilen Online Assessments/Assignments Use Skyward or Epsilen to post assessments or assignments that can then be completed by the student.
Visual Basic A Quick Tutorial VB Review for ACS 367.
More Visual Basic!. Creating a Standalone Program A standalone program will allow you to make a program file that can be run like other Windows programs,
Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes.
Data and variables in Visual Basic. Annoucement Lecture on Thursday 7:30PM C106 Visual Basic download: 
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
I am using Visual Basic 6 for this class. If you want to use a different version, please contact me. Thanks!
Lesson 5 Exponentiation,Order of Operations and Error Handling.
1 4.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works. Directly testing if text boxes.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.
Using Forms and Form Elements In Visual Basic.NET.
Chapter 6 Controlling Program Flow with Looping Structures.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Lesson 4 Mathematical Operators! September 29, 2008 (Pages 62-65)
IE 8580 Module 4: DIY Monte Carlo Simulation
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
OF COURSE I DON'T LOOK BUSY... I DID IT RIGHT THE FIRST TIME
Department Array in Visual Basic
Additional Topics in VB.NET
CHAPTER FOUR VARIABLES AND CONSTANTS
3.3 – Invoke Workflow File Exercise 3.2: Extract as Workflow
Presentation transcript:

Adding Code to the Option Button

Open VB 1.Double click the Calculate button and select General from the Object list box. 2.Add the following code to create two form-level variables: Option Explicit Dim sngPlanetWeight As Single Dim strPlanetName As String

3.Select optMars from the Object list box and add the following code: sngPlanetWeight = 0.38 strPlanetName = “Mars” 4.Select obtJupiter from the Object list box and add the following: sngPlanetWeight = 2.64 strPlanetName = “Jupiter”

5.Select optSaturn from the Object list box and enter: sngPlanetWeight = 1.15 strPlanetName = “Saturn” 6.Select optPluto from the Object list box and enter: sngPlanetWeight = 0.04 strPlanetName = “Pluto”

The final step is to calculate the result and create the output. 7.Double-click the Calculate button and add the following code: Dim intWeight As Integer Dim strWeight As String ‘Calculate Weight intWeight = Fix(sngPlanetWeight * Val(txtWeight.text)) strWeight = Format(intWeight, “####”)

8. The following code will display the results in the caption of the lblOutput label. ‘Display Output lblOutput.Caption = “Your weight on “ & strPlanetName _ & “would be “ & strWeight & “pounds.”

9.Run the program. 10.Enter 150 into the text box. 11.Click the Jupiter option button and click the Calculate button. 12. Click each of the other option buttons and the Calculate button to test them. 13.The answer should change each time. 14.End the program and save your changes.

Homework: Answer True or False for the following: 1.___ Only one option button in a group can be selected. 2.___ The first option button you place on a form automatically creates a frame in which you can place other option buttons. 3.___ The controls you place inside a frame are treated as one unit. 4.___ Drawing option buttons in a frame will automatically associate them with that frame. 5.___ The first option button you add to a form will be selected by default when you run the program.