7/30/2017 0 Comments Windows Vista Home Basic BoxUse VBExpress to Open a File Open Dialog Box in Windows Vista. Hey, Scripting Guy! Taking the Express Route. The Microsoft Scripting Guys. In the last few months, one of the Scripting Guys got to experience something new here in the Seattle area. It's a program being tested in various cities throughout the U. S. However, in the state of Washington, it's known as Good to Go! It works something like this: you pay to get an electronic device that attaches to your windshield. Windows Vista Home Basic Download
You also open an account into which you put a small pile of money. Each time you pass under one of the monitoring devices on the freeway, money is automatically taken from your account. Windows 7 Home Basic FreeBasically, you're paying to drive on the freeway (so much for the . However, the interesting part about Good to Go! What's the point of that, you ask? Why would someone go to the trouble of carpooling, then have to pay? Well, they don't. Steer Clear of Windows Vista Basic;. The Unofficial Windows 10. A search box appears in every Explorer window. Purble Place is the only one of the new games available in the Windows Vista Home Basic edition. This system only charges people who want to use the carpool lane when they're in their cars by themselves. The obvious reason for wanting to drive in the carpool lane is that there are typically fewer cars in that lane; at times the carpool lane is the only lane where the cars are actually moving. As we mentioned, this system is experimental right now, though thousands have already signed up for it. There are plenty of people in the Seattle area who are willing to pay money to take an express route to get to wherever it is they're trying to go. In this month's column, the Scripting Guys have decided to conduct a little experiment of our own. We've decided to show you an express route known as Microsoft. We'll start off by telling you that one of the coolest things about this route is that it really is free; no tolls will be charged no matter where you use this information, how many people are using it, or what time of day it is. Sounds pretty good, doesn't it? Sure, it may seem like there's a small price to pay in that you have to learn some new things, but you just might decide the benefits are worth it. Before we go on, we want to mention that we know we're stepping outside our bounds a bit. Typically the Visual Studio. But since MSDN and Tech. Net seem to be moving more and more toward becoming one big dysfunc—er, happy—family, we're hoping we'll be granted a little leeway here. Also, even though we're talking about working with what has traditionally been a developer tool, we're still talking to Windows. Stick with us for a few more minutes and you'll see what we mean. The first thing you need to do to follow along is install Visual Basic. Don't run off saying . We're not going to go into detail about how to work with Visual Basic Express. There are tutorials in the Help, and the Help itself is actually pretty good. The problem we're going to solve is this: how do you open a file open dialog box in Windows Vista? We explained how to open a file open dialog box from a script a few years ago (please see the column . That article was published in January 2. Windows Vista came into being. The solution uses the User. Accounts. Common. Dialog Active. X. Unfortunately, this control has been removed from Windows as of Windows Vista, which means this solution won't work on newer systems. So instead of writing a script we're going to use Visual Basic to write an application. One of the things this application will do is open a file open dialog box. Yes, that's right, the example we're about to show you builds a full application in Visual Basic. That might sound a little scary at first, but you'll see that by using Visual Basic Express, a full application can be as easy to write as a script. This application will consist of a window, or form, that lets you click a button that will open a file open dialog box. You can then select text files from this dialog box, and our application will read from those text files and display a select set of the contents inside the form. All right, let's get to it. We start by opening Visual Basic Express. The first thing we need to do is to create a new project, which we do by selecting New Project from the File menu. This brings up the New Project dialog box. We named ours Read. Files, as you can see in Figure 1. Figure 1 Creating a new project in Visual Basic (Click the image for a larger view)When the project is first created, it automatically provides a new form to work with. The application we're going to create will present a form to the user that looks like the form in Figure 2. As we mentioned, the form includes a button that, when clicked, will display the file open dialog box, open to the C: \Scripts folder. The user will be able to select one or more text files from anywhere in the file system. The application will then read the first line from each of the selected text files and display the results in the listbox in the form. By default the Toolbox is open on the left side of the Visual Basic window. To add a label to the button, click on the button you just added to the form and type the label you want. Next, click List. Box and again click on the form and drag the mouse to create the listbox. We'll use the listbox to display the lines we read from the text files. That's all we have to do to create our form. Now comes the fun part: we need to make something happen when we click the button. Start by double- clicking the Button control on the form. This will open a code editor with a new subroutine already created for you, the Button. As you can see, this sub is empty at the moment; we need to add the code that will tell the app what to do when the button is clicked. And just what is it we want to do? Well, first we want to do the one thing we promised at the beginning of this column that we'd show you: open a file open dialog box. As with almost everything you're going to do with Visual Basic, we'll use the Microsoft . NET Framework for this. We start by adding a couple of Imports statements up above the sub. Imports System. IO. These statements specify . NET Framework namespaces. We'll be using classes that are in these namespaces, so we import them here so we can simply refer to the classes we want. Note that we said to insert these statements above the sub. Imports statements are global, meaning they can't go inside a subroutine or function; they need to be outside by themselves. In VBScript, unless you add the Option Explicit statement to the top of your script, you don't need to explicitly declare variables. In Visual Basic, it is automatically added so you need to declare all your variables. We're going to need a variable to hold a reference to the Open. File. Dialog object (which just happens to represent the file open dialog box). Dim dlg As Windows. Forms. Open. File. Dialog. Now that we've declared (Dim- ed) a variable of type Open. File. Dialog, we can create a new instance of this object, like so. New Open. File. Dialog(). However, we still haven't displayed the dialog box. First, we need to set some properties. Multiselect = True. Initial. Directory = . We want them to be able to do this, so we set this property to True. We set the Initial. Directory property to C: \Scripts. If you don't set this property, the dialog box will open to the main computer directory. And last, but certainly not least, we set the Filter property. Filter = . We're going to show them only . Setting these properties will give us a file open dialog box that looks something like Figure 3. Figure 3 The Open dialog showing only text files (Click the image for a larger view)Now it's finally time to display the dialog box. We do that with the Show. Dialog method: The Show. Dialog method returns a value indicating whether the user clicked Open to open the selected files or clicked Cancel to dismiss the dialog box. If they click Cancel, we don't want to do anything. So we put the call to Show. Dialog in an If statement to make sure they've clicked Open before we continue. If dlg. Show. Dialog() = . Behind the scenes, the Open button is really the same as an OK button—it's just that displaying Open to the user makes a lot more sense. Now we need to know which file or files the user selected from the dialog box. The filenames are contained in the Open. File. Dialog object's File. Names property, so we set up a For Each loop to read through the filenames contained in this property. For Each str. Name In dlg. File. Names. Oops! We forgot to declare str. Name: Now we need to open each of these files and read from them. The way we do this in Visual Basic is with a Using block. Using sr As Stream. Reader = File. Open. Text(str. Name). A Using block isn't something that VBScript scripters are used to, since it doesn't actually exist in VBScript. Visual Basic is a little better (OK, in many cases a lot better) at managing system resources than VBScript. The point of a Using statement is to make sure that system resources are freed up when we exit the block. In this case, we're just making sure that we're not hanging on to file contents and large blocks of memory. We know that this is sounding a little complicated. But really, just look at it like a Set statement. We're simply creating an instance of a new object, in this case a Stream. Reader object, and assigning it the stream of text returned from the File. Open. Text method. Notice that we pass Open. Text the name of the file we want to open, the file from our File. Names collection we're currently looping through. So our Stream. Reader variable, sr, contains the contents of the file. Now we need another variable: We'll use this variable to store the first line from the text file we just opened: We read the first line from the file by calling the Read. Line method on our Stream. Reader object. Our completed code looks like Figure 4. When you click on the button and then select one or more files in the file open dialog box, the results should look something like Figure 5. Figure 5 The first lines of selected files displayed in the listbox When your application is running just the way you want it to, select Build Read. Files (or whatever your project name is) from the Build menu. This will create an . Microsoft Windows Vista Home Basic DVD- Newegg. Windows Vista Home Basic is the edition of Windows for just the essential home computing needs, such as using e- mail, browsing the Internet, or viewing photos. While it lacks many of the features of Home Premium, it is easier and safer than Windows XP. Easily find everything on your PC and the Internet. Instantly find information on your computer—including documents, e- mails, photos, and even music files—with Instant Search, which is integrated throughout Windows Vista. Stay up to date. See the information you care about instantly with Windows Sidebar and gadgets, which bring real- time information, like weather and news, directly to your desktop. Relive a lifetime of memories. With Windows Photo Gallery, it's easier to download photos from your digital camera and then organize, edit, view, and share them with family and friends. Defend yourself. Windows Defender helps automatically safeguard your PC against pop- ups, slow performance, and security threats caused by spyware and other unwanted software. Defend your kids. With Parental Controls, you can manage the rules for your children's computer use. You can set time limits and manage their access to the web and to PC games.
0 Comments
Leave a Reply. |