Programiranje u VB Uvod

Slides:



Advertisements
Similar presentations
Integrated Business Applications with Databases (D3) Jenny Pedler
Advertisements

ISOM3230 Business Applications Programming
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Modeling using VBA. Covered materials -Userforms -Controls -Module -Procedures & Functions -Variables -Scope.
EXCEL VBA 101 Current Status Waiting Using Excel/VBA to Speed-up Daily Data Processing An Introduction to VBA Yongjun Chen Click Me to Start …
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.
VBA Programming Session #2. Things to Review  Variables  Procedures: Subs & Functions  If…Then  For…Next.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
VB – Core III Functions Sub-routines Parameter passing Modules Scope Lifetime.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
3/9/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup 1 Introduction to VB6 Week 2.
The animation is already done for you; just copy and paste the slide into your existing presentation. Dony Pranadiyanta, ST.
Chapter 7 Code Tables. VB Code Box 7-1 Event Procedure for Compute Button Private Sub hsbExemptions_Change() txtExemptions.Text =Str(hsbExemptions.Value)
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
情報基礎 B Lecture 8 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information.
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’
ENGR 112 Decision Structures.
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
Types and Loops.
Variables,Constants and Data types Variables temporarily stores values during the execution of an application Variables have a name and data type Declare.
Visual Basic Programming Making Decisions: Loops & Decision Structures ©Copyright by Ronald P. Kessler, Ph.D.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
VB .NET Revisit VB .NET Revisit.
Overview of VBA Programming & Syntax. Programming With Objects u Objects –Properties: attributes or characteristics of an object (e.g., font size, color,
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
CS 101 Test 2 Study Guide Acronyms RAD - Rapid Application Development IDE - Integrated Development Environment GUI - Graphical User Interface VB - Visual.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
Types of Visual Basic Data Numeric Data Non Numeric Data.
Visual Basic Programming I 56:150 Information System Design.
Visual Basic Objects / Properties / Methods PropertyAdjective ObjectNoun Part of the application Attribute MethodVerb Action to do something.
Chapter 4 Getting Started with VBA. Subroutines Subroutine is the logical section of code that performs a particular task. Subroutine is also called a.
A: A: double “4” A: “34” 4.
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
Scope Lifetime Modules Procedures. Scope? Where can your variables be seen? Where used? Where abused (reseting the value)? Local and Global = Private.
BACS 287 Programming Fundamentals 5. BACS 287 Programming Fundamentals This lecture introduces the following topics: – Procedures Built-in Functions User-defined.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Multiple forms - SDI & MDI Please use speaker notes for additional information!
Recursion and Branching By: Engr. Faisal ur Rehman CE-105T Spring 2007 By: Engr. Faisal ur Rehman CE-105T Spring 2007.
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Introduction to Programming Lecture 2
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
2. Understanding VB Variables
البرمجة بلغة فيجول بيسيك
Java Hello world !.
Programi,Podaci,Varijable,Računanje- Uvod
للمزيد زورونا على موقعنا الإلكتروني:
مراحل كتابة البرنامج بلغة فيجول بيسك ستديو
Programiranje u VB Osnove
Programiranje Uvod Nikola Vlahović.
Petlje FOR - NEXT.
حلقات التكرار.
البرمجة بلغة فيجول بيسك ستوديو
Pristup podacima Izvještaji
InputBox i naredba IF.
MessageBox.
PROGRAMSKI JEZIK PASCAL
Osnovni simboli jezika Pascal
C++ WORKSHOP Šimec Tino - FOI.
SRETNA SEDMICA.
Programiranje - Naredbe za kontrolu toka programa – 3. dio
Data Types List Box Combo Box Checkbox Option Box Visual Basic 6.0
Active-X Calendar Control
GCSE Computing:: Selection (IF statements)
Programiranje - Naredbe za kontrolu toka programa – 1. dio
Presentation transcript:

Programiranje u VB Uvod Nikola Vlahović

Agenda Izrada izbornika (Menu) Programski kod: (pod)rutine i funkcije Rad s varijablama Kontrola toka programa

Izrada izbornika Caption - naziv naredbe Name - naziv procedure (mnu) checked enabled visible separator (-) &

Programski kod VBa sastoji se od 2 dijela: deklarativni imenovanje varijabli, konstanti. tipova varijabli imenovanje DLL procedura procedure rutine - Sub funkcije - Function svojstva - Property programski kod pohranjen je u modulima: modul forme (*.FRM) standardni modul (*.BAS) modul klase (*.CLS)

Programski kod VBa definiranje rutine Private Sub Form_load () End Sub Private Sub Ispisi(Poruka as String)

Programski kod VBa definiranje funkcije Private Function Dijeljenje( dijeljenik as string, dijelitelj as string ) Dijeljenje = dijeljenik / dijelitelj End Function Public Function Milje(Metri as double) as dobule Milje = …

Programski kod VBa Pomoć prilikom pisanja koda Auto List Members

Programski kod VBa Pomoć prilikom pisanja koda Auto Quick Info bold - trenutni argument [Naziv] - neobavezni argument

Varijable Vrste varijabli Vrste varijabli numeričke Tekstualne Integer - % Long Integer - & Single - ! Double - # Decimal - @ Byte Vrste varijabli Tekstualne String - $ Char logičke - Boolean datum – Date - #...# objekti - Object opće varijable - Variant

Varijable Djelokrug varijabli: Deklariranje varijabli: Implicitno (npr. sifra&, i%, Ime$) explicitno: Dim NazivVarijable [as tipvarijable] Djelokrug varijabli: varijable unutar procedure variable unutar jednog modula varijable koje koristi više modula

Varijable varijable unutar procedure varijable unutar jednog modula uobičajeno - ne čuva vrijednost između poziva procedure Dim Temp As Integer čuva vrijednost između poziva procedure Static Brojac As Integer varijable unutar jednog modula koriste je sve procedure u modulu Private Flag As Boolean varijable koje koristi više modula Public StanjeProzora As Byte

Varijable varijable sa stalnom vrijednosti deklariraju se kao konstante: [Public|Private] Const imekonstante [As tip] = vrijednost Const conPi = 3.14159265358979 Const conPi2 = conPi * 2

Kontrola toka programa Odlučivanje: If… then If… then… else… Select case Petlje: Do… Loop For… Next For each… Next

Kontrola toka programa If… then If uvjet Then naredbe End If If… then If a=1 Then b$=“Stop!” If porez <> 0 Then iznos = iznos + porez msgbox “Iznosu je uvećan” End If

Kontrola toka programa If… then… else… If uvjet1 Then [naredbe-1] [ElseIf uvijet2 Then [naredbe-2]] ... [Else [naredbe-n]] End If If… then… else… If a>0 AND a<10 Then a=a+1 ElseIf a<10 Then a=a+1 Msgbox “Premašen kapacitet!” Else Msgbox “Skladište prazno!” End If

Kontrola toka programa Select case Select Case test [Case listavrijednosti1 [naredbe-1]] [Case listavrijednosti2 [naredbe-2]] . . . [Case Else [naredbe-n]] End Select Select case Select Case matematickaoperacija$ Case “+” a=a+b Case “-” a=a-b Case “*” a=a*b Case “/” a=a/b Case Else Msgbox “Greška! Ponovite unos!” End Select

Kontrola toka programa Do… Loop Do [{While | Until} uvjet] [naredbe] [Exit Do] [naredbe] Loop Do… Loop Do Until i >= 123 r = rnd * 10 i=i+r if i=24 then Exit Do Loop

Kontrola toka programa For… Next For brojac = pocetak To kraj [Step korak] [naredbe] [Exit For] [naredbe] Next [brojac] For i = 0 To 20 Step 2 debug.print i Next [i ]

Kontrola toka programa For each… Next For Each element In grupa naredbe Next element Dim found As Boolean = False Dim thisCollection As New Collection For Each thisObject As String In thisCollection If thisObject = "Hello" Then found = True Exit For End If Next thisObject

Zadatak Izrada aplikacije Alarm modul forme deklariranje varijabli Dim, Static kontrola toka programa If… Elseif… Else… End if nove naredbe InputBox, MsgBox, Beep nove ugrađene funkcije IsDate(), CDate(), Time

Sažetak Izrada izbornika (Menu) Programski kod: Sub, Function Rad s varijablama (dim, static) Kontrola toka programa (If… then…)

Programiranje u VB Uvod Nikola Vlahović