VB'Net Basics - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

VB'Net Basics

Description:

Similar to JOptionPane dialogs in Java. Only use on exceptional basis! Keyboard Issues ... A Sub call is always a standalone statement. ... – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 46
Provided by: cisUso
Category:
Tags: basics | net | subdialogs

less

Transcript and Presenter's Notes

Title: VB'Net Basics


1
VB.Net Basics
  • ITE 285

2
Forms and Controls
  • __________ Visual Object that is the basis of the
    User Interface
  • Call a Window at __________
  • Contains the __________
  • __________ Object places on the form to enable
    customizable activities
  • Visual (most)
  • Display some information
  • Allow the user to __________ with program

3
Objects
  • One of the most basic elements of the VB Program
  • Objects Have
  • __________
  • __________
  • __________

4
Object Properties
  • Determine an objects __________ (and sometimes
    behavior)
  • Text Field
  • Visible
  • Font
  • BorderStyle
  • Enabled

5
Object Events
  • An action initiated by the user or the operating
    system that the program can respond to
  • Basis of Event Driven Programming
  • Events are __________
  • When Fired, __________ will execute
  • Each Event is Associated with a __________

6
Object Methods
  • __________ that performs a task relative to a
    specific object
  • Things the objects already know how to do
  • Show
  • SetFocus

7
Designing a GUI
  • Form the on screen window your program owns
  • TOE Chart __________ , __________ , __________
  • Task your interface helps user perform
  • Object the VB control you will use
  • Fired Event for which you will write code to
    respond. May be N/A.
  • Also dont forget a simple sketch!!!

8
TOE Chart
9
Form
  • Part of the Windows Forms Class
  • Container for __________
  • Always orient a forms as defined by the
    __________

10
Form Properties
  • Prefix __________
  • Text
  • Start Position
  • Size.Width
  • Location.X, Location.Y
  • FormBorderStyle
  • Visible
  • Enabled

11
Form Methods
  • Form1.Show()
  • Form1.ShowDialog()
  • Form1.Close()
  • Form1.Hide()

12
Form Events
  • Form1_Load()
  • Form1_Activated()
  • Form1_Deactivated()

13
Command Button
  • Task __________
  • Common Properties
  • __________ (the variable name)
  • __________ (what is displayed)
  • Prefix __________
  • Click event procedure where you put code.

14
Textbox
  • Task __________
  • Common Properties
  • Name, Text
  • TextAlign, Readonly
  • CharacterCasing
  • Multiline
  • Prefix __________

15
Label
  • Task __________ __________ __________ __________
  • Common Properties
  • Name, Text
  • UseMnemonic
  • Prefix __________ non-default name only needed
    if you use at runtime

16
Checkbox
  • Task __________ __________
  • Common Properties
  • Name, Text
  • Checked (a boolean)
  • Prefix __________

17
Radiobutton
  • Task __________ __________ __________ __________
  • Common Properties
  • Name, Text
  • Checked
  • Prefix __________
  • Usually with Groupbox

18
Groupbox
  • Purpose
  • __________ __________ __________
  • Define a set of radiobuttons
  • Common Properties
  • Prefix __________

19
Best Control
  • __________ __________
  • __________ __________
  • __________ __________
  • __________ __________

20
More on Properties
  • We will be using many other properties of these
    controls!!

21
Not in the Toolbox
  • __________
  • __________
  • Similar to JOptionPane dialogs in Java
  • Only use on exceptional basis!!!!!

22
Keyboard Issues
  • Focus
  • __________ __________ __________ __________
  • Focus is advanced to next control by mouse click
    on it or pressing the Tab key.
  • Tab Order
  • __________ __________ __________.
  • Edit order interactively ViewgtTab Order
  • Or TabIndex property of each control.
  • Access Keys
  • __________ in Text value works with Alt- as a
    keyboard shortcut

23
VB.Net IDE
  • IDE __________ __________ __________
  • Contains source code editor, compiler, debugger,
    help.
  • Similar in concept to JGrasp or Eclipse.

24
New Project Dialog
  • Make sure you set the location __________ _____
  • Name is used for new folder as well as files.

25
Project Workspace w/Form
26
Toolbox
  • Place control on Form
  • __________
  • __________
  • Click in toolbar if hidden
  • Your controls are objects, instances of the
    control class.

27
Properties
  • If hidden
  • AZ button sorts alphabetically
  • Click in value field for button to see predefined
    list

28
Writing Code
  • When using the Design view to add controls and
    adjust Properties, code is written for you.
  • Add your code in Code View
  • __________ __________ __________ __________
    __________ __________ __________ __________
  • Can switch views with tabs at top
  • Most of our code for now will be in Event
    procedures

29
Compiling and Running
  • Build menu compiles and links
  • Running
  • __________ _______
  • Play button in toolbar.
  • F5

30
Build __________ Errors
  • ALWAYS click No on a build error!
  • Task List at bottom left will show error msg.
  • Dbl-click msg to highlight suspected line of code
    in source window.

31
Solution Explorer
  • __________ __________ from the default Form1 to
    something like frmMain (in Properties).
  • Next, rename the file the same, eg frmMain.vb
  • Set the projects __________ to the new name
    (menu ProjectgtProperties)

32
Project FilesDefault location is underMy
DocumentsgtVisual Studio ProjectsgtYourProjectName
33
Project Files 2
  • You can load project by dbl-clicking Project
    (.vbproj) or Solution (.sln) file.
  • The compiled executable (.EXE) is in the
    __________ .
  • NEVER save files to a floppy using FilegtSaveAs
    from inside Visual Studio!
  • Always save everything, exit VS, then copy entire
    project folder.

34
VB.Net Language Basics
35
Comments
  • Comments are text we want __________
    are NOT executable statements
  • VB comments indicated with single-quote
    (apostrophe) and are green in IDE
  • I expect comments for identifying yourself,
    assignment, purpose, and elsewhere for clarity
  • Older code may use REM (remark)

36
Variable Declarations
  • Associate a variable name to be used with a data
    type
  • Form __________
  • May have Const, Private or Public instead of Dim
  • Initialize Dim strName As String Joe
  • __________ __________ IDE keeps case consistent
    w/ declaration

37
VB.Net Data Types
38
Literal Values
  • 4 Integer
  • 4.24 Double
  • John String
  • y Char from context
  • 3/1/2006 Date

39
Operators
  • Assignment
  • Arithmetic
  • Relational (comparison)
  • Logical
  • Dot operator

40
Assignment
  • The __________ serves as the Assignment Operator
  • In an expression such as yy1
  • Right hand side is evaluated
  • Result is copied to left hand side variable

41
Arithmetic Operators
  • Addition
  • - Subtraction
  • Multiplication
  • / Division
  • \ Integer Division
  • Mod Modulus or remainder (like Java )
  • __________ __________ is similar to Java, ( ) to
    override it.

42
Relational Logical Operators
  • Equality test with __________ (not )
  • Not Equal __________ instead of !
  • gt, lt, gt, lt just like Java
  • __________ instead of
  • __________ instead of
  • __________ instead of !

43
Calling Procedures
  • A __________ is like a Java method
  • __________ (short for subroutine) is like a Java
    void method.
  • A Sub call is always a standalone statement.
  • __________ is like a Java method that returns a
    result that replaces the call in the larger
    expression.

44
Event Handling Procedures
  • For now we write most of our code in Event
    Handling Procedure Subs.
  • Similar to Java __________
  • We never call these directly
  • Instead .NET passes event from interface, calling
    our Event Handler Sub when needed.
  • __________ event list can respond to more than
    one event.

45
Built-In Functions
  • Many functions follow OOP paradigm
  • string methods, e.g. Name.IndexOf(i)
  • Math functions e.g. Math.Sin(x)
  • __________ functions are standalone
  • Val(mystring), CDbl(mystring), CInt(mystring)
  • IsNumeric( mystring)
  • FormatNumber(x, 2)
  • Financial functions, random numbers
Write a Comment
User Comments (0)
About PowerShow.com