Presentation is loading. Please wait.

Presentation is loading. Please wait.

Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

Similar presentations


Presentation on theme: "Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications."— Presentation transcript:

1 Running External Applications 1

2 There are times when you may wish to run an external application from a VB application. 2 External Applications

3 As another example, you are asked to create a VB program that tests a user’s knowledge of Microsoft Word. Part of the test is multiple choice (like Assignment-6) and part is hands-on. From your VB program, you want to open Word and a specific document, have the user make changes to the document, and then save it. This can be done using the Shell Method or the Process Class. 3 External Applications After learning about these two options, we will use them to create the interface shown on the previous slide. After learning about these two options, we will use them to create the interface shown on the previous slide.

4 Shell(“application_name”, windows_style) Shell(“c:\windows\notepad.exe”,AppWinStyle.NormalFocus) Shell(“c:\Program Files\Microsoft Office\Office14\winword.exe FontTest.doc”,AppWinStyle.NormalFocus) 4 Shell Method There are two additional parameters, but we will not examine them. See help on the Shell method for details.Shell method There are two additional parameters, but we will not examine them. See help on the Shell method for details.Shell method For additional window styles see: http://msdn.microsoft.com/en-us/ library/microsoft.visualbasic.appwinstyle.aspx For additional window styles see: http://msdn.microsoft.com/en-us/ library/microsoft.visualbasic.appwinstyle.aspx Since the paths can vary, using the Shell method on different computers can cause problems. Even on the same computer, there can be problems. Since the paths can vary, using the Shell method on different computers can cause problems. Even on the same computer, there can be problems. You cannot split a string across two lines. I needed the room! If no path is specified, VB searches the Documents folder not debug. If no path is specified, VB searches the Documents folder not debug.

5 Process.Start (“application_name”) Process.Start(“c:\windows\notepad.exe”) Process.Start (“document_name”) Process.Start(“FontTest.doc”) 5 Process Class Since the paths can vary, using the Process.Start on different computer can cause problems. Even on the same computer, there can be problems. Since the paths can vary, using the Process.Start on different computer can cause problems. Even on the same computer, there can be problems. If no path is specified, VB searches the debug folder not Documents. If no path is specified, VB searches the debug folder not Documents. The application associated with the file type is used. For additional information see Help on the Process.ClassProcess.Class For additional information see Help on the Process.ClassProcess.Class

6 Let’s look at VB and see how to create the interface to execute these three applications. 6

7 Accessing the Web 7

8 The first example we will look at is a VB project that opens the CIS 400 home page. This is done by using the WebBrowser control and setting some of its properties such as: AllowNavigation Dock Url 8 Accessing the Web For additional details about the WebBrowser class, visit: http://msdn.microsoft.com/en-us/library/5d67hf8a.aspx For additional details about the WebBrowser class, visit: http://msdn.microsoft.com/en-us/library/5d67hf8a.aspx

9 9 Let’s look at VB and see how to create this Web interface.

10 As another example, suppose you are working for the IT department of a school system, and you are asked to limit student access to only specific Web sites and links on those sites. Remember, in the previous topic, we were able to run IE from with VB. Unfortunately, IE has an address text box in which users can type any URL. To prevent this, you will use VB to create a browser interface that does NOT contain an address text box, thereby preventing users from typing a URL. 10 Accessing the Web You will also have to use some WebBrowser methods.

11 11 Let’s look at VB and see how to create this Web interface. ListBox of approved sites.


Download ppt "Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications."

Similar presentations


Ads by Google