Visual basic - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Visual basic

Description:

'Romeo'&'Juliet'='RomeoJuliet' String concatenation or & ij 15Mod4. Integer division ... String (characters), date and boolean ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 19
Provided by: RobertM7
Category:
Tags: basic | visual

less

Transcript and Presenter's Notes

Title: Visual basic


1
Visual basic
  • The basics

2
What is it?
  • A programming language
  • Create programs to run on windows machines
  • Once program (.exe) is created,should work on
    any windows machine (even is visual basic is not
    installed)
  • Programs can be anything calculate groundwater
    levels, games, or even a virus

3
Graphical interface
  • Design interface to program (drag and drop)
  • Add code to interact with interface
  • Compile
  • Fix bugs
  • Run

4
Options for graphical interface
  • Whole list of options
  • Select object that you want
  • Draw on form
  • Modify controls at right side (caption, name, etc)

5
The code
  • Write code controlled by each item
  • Usually, object oriented
  • Program flow controlled by user, not necessarily
    sequential

6
Mathematical operations
7
Other operators
8
variables
  • Should be declared
  • Dim total as integer
  • Dim myName as string
  • If not declared, VB automatically declares it
    using a default
  • byte (0-255),integer (-32,768 to 32,767),single
    (-3.2E38 to 3.4E38)
  • long,double,currency, and decimal
  • String (characters), date and boolean
  • Must be less than 255 characters, no spaces, and
    cannot begin with a number.

9
objects
  • An embedded object
  • Has attributes
  • Radius.text

10
statements
  • If .thenelse
  • If z.Text x.Text y.Text  Then
    display.Caption "Correct" Image2.Visible
    "true" Line1.Visible "true" Else
    display.Caption "Wrong" Image2.Visible
    "false" Line1.Visible "false" End If

11
loops
  • Do while
  • Do while counter lt1000
  •              num.Textcounter
  •              counter counter1
  •  Loop
  • For..Next
  • For  counter1 to 10
  •              display.Textcounter
  • Next

12
Okaynow how do you do it?
  • Start visual basic
  • Click on standard.exe
  • Double-click on form
  • Make it look like this
  • Run, compile

13
Adding an interface
  • Draw interface
  • Set properties
  • Write event code

14
Compile and run
  • May show bugs

15
Can save as executable
  • Under file, save as exe
  • This file can be transferred elsewhere and run.

16
components
  • Hit cntrl-T
  • A wide variety of possible controls to add
  • Quicktime, for example
  • We chose Microsoft Common Dialog Control

17
Open a file and play it
  • Private Declare Function sndPlaySound Lib
    "winmm.dll" Alias "sndPlaySoundA" (ByVal
    lpszSoundName As String, ByVal uFlags As Long) As
    Long
  • Private Sub Command1_Click()
  • ' declare the file name as string variable
  • Dim FileName As String
  • 'This allows us to access a WIN32 function in VB.
  • ' now open the dialog box
  • CommonDialog1.Filter "Wav files (.wav)"
  • CommonDialog1.FilterIndex 1
  • CommonDialog1.ShowOpen
  • 'now set the file name to whatever you picked
  • FileName CommonDialog1.FileName
  • 'play it
  • sndPlaySound FileName, SND_ASYNC
  • End Sub

18
More weird stuff
  • Do a cntr-T and add Microsoft Direct
    text-to-speech
  • Now you should see a pair of lips
  • Add a text box and another button and
  • Private Sub Command2_Click()
  • DirectSS1.Speak Text1.Text
  • End Sub
Write a Comment
User Comments (0)
About PowerShow.com