Download presentation
Presentation is loading. Please wait.
Published byRitva Sala Modified over 5 years ago
1
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.
2
Sık Kullanılan VB Değişken Tipleri
3
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
4
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
5
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.
6
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
7
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.
8
Örnek Değişken İsimleri
You should use variable naming conventions that denote the type and scope.
9
Değişkenlere Değer Atanması
Variable = Expression X = 12.5 Cmax = X Area = * Radius ^ 2 Label = "Name: " Str = FirstStr + LastStr J = J + 1
10
Aritmetik İşlemler
11
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)
12
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 = D+ 23 Const MaxCount As Integer = 100
13
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
14
Toplama programı için Denetimler ve Özellikleri
15
Dizilerle Alakalı Fonksiyonlar
16
Sık Kullanılan Matematiksel Fonksiyonlar
17
Format fonksiyonu
18
Dizilerin Birleştirilmesi
Str1 = "TEN" Str2 = "THOUSAND" Str1 & " " & str2 & " DOLLARS" Str1 + " " + str2 + " DOLLARS" TEN THOUSAND DOLLARS
19
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
20
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
21
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.