Chapter 14 Communicating with Other Applications Outline and Objectives - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Chapter 14 Communicating with Other Applications Outline and Objectives

Description:

Web Page Programming with VBScript ... VBScript is a subset of the VB programming language that is used to make Web pages interactive. ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 19
Provided by: fay85
Category:

less

Transcript and Presenter's Notes

Title: Chapter 14 Communicating with Other Applications Outline and Objectives


1
Chapter 14 Communicating with Other
ApplicationsOutline and Objectives
  • OLE Object Linking and Embedding
  • Accessing the Internet With Visual Basic
  • Web Page Programming with VBScript

2
14.1 OLE
  • Is the evolving technology that allows
    programmers to use Visual Basic to glue together
    applications like spreadsheet and word
    processing.
  • The three types of OLE are known as automation,
    linking, and embedding.
  • With automation, you control an application from
    your program.
  • With linking and embedding, you bring an
    application into your program.

3
OLE Automation
  • An Excel spreadsheet or a Word document can be
    specified as an OLE Automation object.
  • The application can be declared as an object with
    the Set statement and CreateObject function.

4
OLE Automation
  • OLE Automation involves the following four
    steps
  • Declare an object variable with a Dim statement
  • Create an OLE Automation object with a
    CreateObject function and assign it to the
    variable with a Set statement
  • Transfer commands and/or data to the OLE
    Automation object to carry out the desired task
  • Close the object and assign the value Nothing to
    the object variable.

5
Example 2, pp. 669creates a Word document and
saves the document to a file
  • Private Sub cmdCreate_Click()
  • Dim objWord As Object
  • Set objWord CreateObject("Word.Basic")
  • objWord.FileNewDefault
  • objWord.Insert "I can resist anything."
  • objWord.Wordleft
  • objWord.Bold
  • objWord.Insert ", except temptation
  • objWord.FileSaveAs App.Path "\QUOTE.DOCThe
    word document is created
  • objWord.FileClose
  • Set objWord Nothing
  • End Sub

6
The OLE Container Control
  • An OLE Container control provides a bridge to
    Windows applications.
  • The application can be either linked or embedded
    through the OLE Container control.
  • With linking, a link is established to the data
    associated with the application and only a
    snapshot of the data is displayed.
  • With embedding, all the applications data are
    actually contained in the OLE Container control
    and no other application has access to the data.

7
14.2 What is the Internet?
  • Internet stands for inter-net worked
    communication
  • The Internet is a collection of thousands of
    networks linked by a common set of technical
    protocols.
  • The Internet is a global system of networked
    computers.
  • The Internet consists of the following
    components
  • The World Wide Web (WWW)
  • Usenet newsgroup
  • E- mail (SMTP)
  • File Transfer Protocol (FTP)
  • Telnet

8
Internet
  • To add the Web Browser Control to Your Visual
    Basic ToolBox
  • Invoke Visual Basic
  • Press CtrlT to invoke the Components dialog box
  • Click the check box next to Microsoft Internet
    Controls.
  • Click the OK button
  • The Web Browser icon should now appear in your
    toolbox.

9
Example of A Simple Web Browser
10
Example 1, pp. 678 - creates a simplified web
browser
  • Private Sub cmdRetrieve_Click()
  • 'Calls up the URL typed in the Text Box
  • WebBrowser1.Navigate (txtURL.Text)
  • End Sub
  • Private Sub Form_Load()
  • WebBrowser1.GoHome 'Calls up Internet
    Explorer's home page
  • End Sub
  • Private Sub Form_Resize()
  • 'Resizes the Web Browser control with the Form,
    as long
  • 'as the form is not minimized.
  • 'Occurs when an object is first displayed
  • If Form1.WindowState ltgt 1 Then
  • WebBrowser1.Width Form1.ScaleWidth
  • WebBrowser1.Height Form1.ScaleHeight - 740
    'Subtract Toolbar height
  • End If
  • End Sub

11
Example continues
  • Private Sub WebBrowser1_NavigateComplete(ByVal
    URL As String)
  • 'Is activated when the HTML control finishes
  • 'retrieving the requested Web page.
  • 'Updates Text Boxs URL Display to show current
    URL
  • On Error Resume Next 'Eliminates error
    messages
  • txtURL.Text WebBrowser1.LocationURL
  • End Sub

12
Web Browser Control
  • Additional properties of the Web Browser control
    are
  • LocationURL gives the URL of the current page.
  • LocationName gives the title of the current
    page.
  • Busy Has the value True if the control is
    downloading a file or navigating to a new
    location.
  • Some additional methods of the Web Browser
    control are
  • GoForward Undoes the most recent GoBack method.
  • GoSearch Goes to the users web searching page.
  • Stop Cancels the current operation of the
    control.

13
Web Browser Control
  • Some additional events of the Web Browser control
    are
  • BeforeNavigate Triggered right before the
    control moves to a new location
  • ProgressChange Triggered periodically as the
    downloading continues.
  • DownloadComplete Triggered when the download is
    complete, halted, or failed.

14
Web Page Programming with VBScript
  • Web browser displays Web pages created as text
    files, called HTML (HyperText Markup Language)
    documents.
  • VBScript is a subset of the VB programming
    language that is used to make Web pages
    interactive.

15
HTML
  • An example of an HTML document
  • ltHTMLgt
  • ltHEADgt
  • ltTITLEgtIntroduction to Visual Basic lt/TITLEgt
  • lt/HEADgt
  • ltCENTERgt
  • ltA HREF"http//www.eas.asu.edu/csedept/"gt
  • ltIMG SRC"../dlogo.gif" border0 ALT"CSE
    Department Home Page"gt
  • lt/Agt
  • lt/CENTERgt
  • ltBODY bgcolor"FFF9E6"gt
  • ..
  • ..
  • lt/BODYgt
  • lt/HTMLgt

Every html document starts with this tag
Creates a hyperlink to an image
Ending tag
16
HTML
  • Tags are used to mark up text with display
    instructions
  • The combination of a pair of tags and the text
    enclosed is called an element.

17
Placing ActiveX controls in HTML documents
  • With Internet Explorer, ActiveX controls, such as
    textboxes, command buttons, and user-built
    controls, can be placed on Web pages.
  • The ActiveX control pad makes it easier to place
    text, controls, and programs into HTML document.

18
Steps to Create ActiveX Control
  • Create a New Project
  • From the File menu, select Add Project command,
    click on ActiveX Control (VB uses the same
    metaphor for building ActiveX Controls as
    building applications)
  • Draw the Visual Interface for the Control
  • Write event driven Code
  • Use and Test the Control
  • Prepare your Control for Internet Explorer
  • To learn more on the ActiveX Control Pad, enter
    the following address
  • http//msdn.microsoft.com/vbasic/technical/tutori
    al/activex.aspintro
Write a Comment
User Comments (0)
About PowerShow.com