Değişkenler Variables can temporarily store the value of data in memory during the execution of your program. They are often referred to as containers.

Slides:



Advertisements
Similar presentations
Chapter 3: Using Variables and Constants Programming with Microsoft Visual Basic 2005, Third Edition.
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
AE6382 VBA - Excel l VBA is Visual Basic for Applications l The goal is to demonstrate how VBA can be used to leverage the power of Excel u VBA syntax.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Lec2 P 1 CP2030 Visual Basic For C++ Programmers Copyright © University of Wolverhampton CP2030 VBFC Lecture 2 Back to Index v Basic Data Types v Arithmetic.
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
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.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Apply Sub Procedures/Methods and User Defined Functions
Chapter 3: Using Variables and Constants
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
Tutorial 11 Using and Writing Visual Basic for Applications Code
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
Why to Create a Procedure
Lab 01 Forms in excel Tahani ALdweesh Insert form into your project. 2. Change form’s properties. 3. Put controls on the form. 4. Change controls’
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Chapter 3 P. 1 Data - Variables and Constants Definition A variable is a value which can change during program execution. A constant is a value which can.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Three Using Variables and Constants.
Programming with Microsoft Visual Basic th Edition
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
Controlling Program Flow with Decision Structures.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Programming with Microsoft Visual Basic 2012 Chapter 3: Using Variables and Constants.
Subprocedures and Functions Visual Basic provides a number of facilities for creating modularized and reusable program code. The two you will learn about.
Değişkenler Variables can temporarily store the value of data in memory during the execution of your program. They are often referred to as containers.
Visual Basic Fundamental Concepts
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Egyptian Language School Computer Department
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
VBA - Excel VBA is Visual Basic for Applications
VBScript Session 1 IT Professional Academy.
Object-Oriented Programming: Classes and Objects
Chapter 3: Using Variables and Constants
Working with Forms in Visual Basic
2. Understanding VB Variables
Microsoft Access Illustrated
Object-Oriented Programming: Classes and Objects
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Visual Basic..
Chapter 2 Elementary Programming
Chapter 6 Variables What is VBScript?
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CIS16 Application Development Programming with Visual Basic
CS285 Introduction - Visual Basic
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 1/15/2019.
CHAPTER FOUR VARIABLES AND CONSTANTS
Intro to Programming Concepts
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Presentation transcript:

Değişkenler Variables can temporarily store the value of data in memory during the execution of your program. They are often referred to as containers for various types of data. But in reality, they are address placeholders to a memory location in your computer. In addition, variables act as templates, defining what type of data should be kept in a memory location and its allowable size.

Sık Kullanılan VB Değişken Tipleri

Dim StudentName As String Dim StudentName As String * 30 The syntax for assigning a variable type to a variable name is as follows: [declaration type] değişkenİsmi As değişkenTipi Örnekler: Here is an example of a variable called myInteger declared as an integer variable type: Dim benimSayim As Integer Dim Counter As Integer Dim Area As Single Dim StudentName As String Dim StudentName As String * 30 Dim TaxRate As Single, Income As Double, Taxes As Double, Dependents As Integer

Declaring Variables and Scope Variables derive their scope from either their location in the program code or their declaration type. Variables declared in a procedure (for example, the form load event or a button click event) with the keyword Dim have what’s known as procedure-level scope; they are called local variables. That is, the variable maintains its value only throughout the execution of that procedure. You can also declare variables in a procedure with the keyword Static. Variables declared with the keyword Static retain their value the entire time your program is executing. Örnekler: Static benimSayim as String Dim benimGunum as Date

Variables declared with the keyword Dim in a form’s code window, but outside of any subprocedures or functions, are considered form-level variables. These code areas outside procedures are known as the General area. Form-level variables are accessible to any procedures or functions located in that form’s code window. You can use them when you want a variable to retain its value or scope when moving from one procedure to another.

Option Explicit A nice feature of Visual Basic is its ability to warn you or prevent you from typing a variable name without explicitly declaring it as a variable. To implement it, simply type the statement Option Explicit in the first line of a form’s code window You only need one Option Explicit statement for any Visual Basic project. Tools * Options * Editor * Require Variable Declaration

Değişken, Kontrol, Procedure isimlendirme kuralları All names must begin with a letter. Do not use periods or spaces in names. Variable names can be up to 255 characters in length. Control and module names can be up to 40 characters in length. Do not use any Visual Basic keywords.

Örnek Değişken İsimleri You should use variable naming conventions that denote the type and scope.

Değişkenlere Değer Atanması Variable = Expression X = 12.5 Cmax = X Area = 3.141593 * Radius ^ 2 Label = "Name: " Str = FirstStr + LastStr J = J + 1

Aritmetik İşlemler

Aritmetik İfadeler 2 * j + k -1 2 * (j + k – 1) first + second – third (a ^ 2 + b ^ 2) ^ 0.5 4 * Pi * Radius ^ 3 / 3 (5 / 9) * (F – 32) b ^ 2 - (4 * a * c) (2 * x - 3 * y) / (u + v)

Sabitler Once you declare a constant, its value cannot change during program execution. Constants generally denote numbers or strings that do not need to change throughout the life of a program’s execution. [Public or Private] Const sabitİsmi As [type] = expression Örnekler: Public Const VERSION_ NUMBER as String = “Version 1.2.3” Public Const PI as Double = 3.14 Const TaxRate As Single = 0.28 Const Avogadro As Double = 6.0225D+ 23 Const MaxCount As Integer = 100

Basit bir Toplama Programı Option Explicit Private Sub cmdAdd_ Click() Dim lsOperand1 As Single Dim lsOperand2 As Single Dim lsResult As Single lsOperand1 = Val( txtOperand1.Text) lsOperand2 = Val( txtOperand2.Text) lsResult = lsOperand1 + lsOperand2 lblResult. Caption = lsResult End Sub

Toplama programı için Denetimler ve Özellikleri

Dizilerle Alakalı Fonksiyonlar

Sık Kullanılan Matematiksel Fonksiyonlar

Format fonksiyonu

Dizilerin Birleştirilmesi Str1 = "TEN" Str2 = "THOUSAND" Str1 & " " & str2 & " DOLLARS" Str1 + " " + str2 + " DOLLARS" TEN THOUSAND DOLLARS

Displaying Output - Print Statement Dim Student As String, X As Integer, C1 As Single, C2 As Single Student = "Aaron" X = 39 C1 = 7 C2 = 11 Print "Name:", Student, X, (C1 + C2) / 2 Print "Name:"; Student; X; (C1 + C2) / 2

Koda Yorum Eklenmesi Comments provide a convenient means to document a program (i. e., to provide a program heading, to identify important variables, to distinguish between major logical segments of a program, to explain complicated logic, etc.). Örnek: 'Program to Calculate the Roots of a Quadratic Equation . . . . . X1 = (-b + root) / (2 * a) 'calculate the first root X2 = (-b - root) / (2 * a) 'calculate the second root Print X1, X2

VB Programlarının Derlenmesi To run your Visual Basic program outside of the design-time IDE, you need to compile your project into an executable file. This process takes your project’s files and turns their information into machine code that is contained in one executable file (exe). Once you create an executable file, it can be distributed and accessed by double-clicking it or opening it in a Microsoft environment such as Windows 95, Windows NT, Windows 98, Windows Millennium, Windows 2000, or Windows XP. To compile your project, simply click the File menu and select Make *.exe, where the asterisk (*) represents the name of your project. msvbvm60.dll, msvbvm50.dll