Learn VB.NETby Chuck EasttomWordware Publishing, Inc.Copyright © 2002, Wordware Publishing, Inc. All Rights Reserved 2320 Los Rios Boulevard Plano, Texas 75074No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc. Printed in the United States of America1-55622-952-6 10 9 8 7 6 5 4 3 2 1 0201 Product names mentioned are used for identification purposes only and may be trademarks of their respective companies.All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address.
Telephone inquiries may be made by calling: (972) 423-0090Contents Summary Chapter 1Windows Applications with VB.NET. 1Chapter 2Fundamentals of Programming with VB.NET. 23Chapter 3Object-Oriented Programming. 51Chapter 4The.NET Architecture. 65Chapter 5Introduction to Database Programming.
81Chapter 6More Windows Programming with VB.NET. 107Chapter 7ADO.NET.
A Variety of R Programs. Contribute to ezgraphs/R-Programs development by creating an account on GitHub.
139Chapter 8Web Development with VB.NET. 149Chapter 9Creating Custom Windows Controls. 171Chapter 10 Console Applications. 183 Chapter 11 TCP/IP Programming. 193 Chapter 12 Software Design with VB.NET. 207 Chapter 13 Computer Science with VB.NET. 221 Chapter 14 Object Models.
239 Chapter 15 Encryption in VB.NET. 251 Chapter 16 Deploying Your Application. 261 Chapter 17 Converting Existing Applications. 271 Appendix AKeywords. 283 Appendix B Other Resources. 289 Appendix C Answers to Review Questions. 291 Appendix DHTML Primer.
305 Index. 313iiiContents Introduction. Xiii Chapter 1 Windows Applications with VB.NET. 1 Introduction. 1 Getting Started with VB.NET. 1 Common Components and Their Properties.
11 Components. 11 Component Properties. 14 Common Programming Terms. 17 The Drop-Down Menu. 18 File. 18 Edit. 18 View.
19 Project. 19 Build. 20 Debug. 20 Shortcut Keys. 21 Naming Conventions. 21 Summary. 22 Review Questions.
22 Chapter 2 Fundamentals of Programming with VB.NET Introduction. Programming Terms. Operators and Statements. Functions and Procedures.
Decision Structures. Select Case. The Message Box.
Input Box. Review Questionsvi.40 47 49 49Chapter 3 Object-Oriented Programming. Programming Terms. Access Modifiers.
Shared Members. Review Questions. 63Chapter 4 The.NET Architecture. Virtual Execution System. Component Architecture. Managed Code.
Garbage Collection and Object Management. Language Fundamentals of VB.NET. Event Handling. Error Handling. System Namespace. File I/O.
Data Types and the Common Type System. Review Questions. 79Chapter 5 Introduction to Database Programming Introduction to Databases. Creating a Database and Tables. Database Practice. A Brief History of SQL. 89ContentsThe Basics of Data Binding.
89 A Basic Data-bound Application. 90 Complex Data Binding. 104 Summary. 105 Review Questions. 106 Chapter 6 More Windows Programming with Introduction.
Common Components. MDI Applications. Built-in Functions. String Functions.
Math Functions. Review Questions.VB.NET. 137Chapter 7 ADO.NET. XML Documents.
ADO.NET Architecture. Maintaining State. Managed Providers. Disconnected Layer. State of Data. Populating Programmatically Summary. Review Questions.
147Chapter 8 Web Development with VB.NET. Technological Background. Web Forms. A Simple Web Form. HTML Components. Text Field. Text Area.
List Box. Check Box. Windows Forms. Web Forms vs. Traditional ASP Data-bound Web Forms. Web Services. How Web Services Work.
Review Questions.viii.Chapter 9 Creating Custom Windows Controls. Modifying an Existing Component. Compound Components.
Creating Components from Scratch. Components without a User Interface.
Web Controls. Review Questions. 182Chapter 10 Console Applications Introduction. Console Application Objects. Complex Console Applications.
Review Questions. 191Chapter 11 TCP/IP Programming Introduction. The Winsock Control. More About the Winsock.
198.156 157 158 159 160 161 161 162 165 165 167 168 168 169 170ContentsUDP Applications. The Bind Method. OSI Model. Network Connectivity Summary. Review Questions.Chapter 12 Software Design with VB.NET. Types of Errors. Microsoft Solutions Framework.
Three-Step Plan. Setting Project Debugging Options. The Build Window. Review Questions. 220Chapter 13 Computer Science with Introduction. Data Structures.
Other Structures. Sorting Algorithms. Other Algorithms. Optimizing for Speed. Review Questions.
237VB.NET.199 201 201 203 204 205ixContentsChapter 14 Object Models. Outlook’s Object Model. Internet Information Server.
The ASP Request Object. The ASP Response Object. The ASP Session and Application Objects The ASP Server Object. The ASP BrowserType Object. Review Questions.x. 249Chapter 15 Encryption in VB.NET. History of Encryption.
VB Simple Substitution Encryption. Advanced Encryption Concepts. My Cryptography Algorithm for More Serious Cryptographers. More Encryption.
Creating Secure Applications. Review Questions.
259Chapter 16 Deploying Your Application. Packaging Code.
Creating Cabinet Files. Configuring the.NET Framework. Creating Configuration Files. Application Configuration Files. Machine/Administrator Configuration Files.
Security Configuration Files. Review Questions. 269Chapter 17 Converting Existing Introduction. Upgrade Considerations. Early Binding. ADO Data Access.
The Date Data Type. Fixed-Length Strings. 275Applications.ContentsInternet Information Server (IIS) Applications Converting Forms. Windows API.
Error Handling. Using Constants. The Upgrade Wizard. Summary.276 276 276 276 277 278 278 282Appendix AKeywords. 283 Appendix B Other Resources. 289 Appendix C Answers to Review Questions.
291 Appendix DHTML Primer. 305 Index.
313xiAcknowledgments This book has been a tremendous undertaking, and I could not have done it alone. I have several people to thank for this. First of all the people at Wordware Publishing.
Jim Hill and Wes Beckwith have always been absolutely wonderful to work with. Without them, I would not be writing programming books today. I also owe a great debt to Beth Kohler. She edits the rough drafts and saves me from embarrassing myself!
I also wish to thank students who looked at rough drafts of chapters and examined source code. They allowed me to confirm that this book truly could teach the beginner how to use VB.NET.
Finally, my wife, Misty, and my son, AJ, who are always patient when I am laboring in the den for hours on a book. Their understanding allows all this to be possiblexiiIntroduction When Visual Basic 1.0 was introduced in 1991, it revolutionized Windows programming.
Before the advent of Visual Basic, programmers had to code everything by hand, the hard way. A simple task such as placing a button on the screen required some rather intricate programming. Visual Basic changed all this. It allowed the programmer to use components to build the GUI (Graphical User Interface) and then they could simply concentrate on the actual application. Versions 2 and 3 of Visual Basic simply added some more components and a bit more functionality; however, version 3.0 was still quite limited. Most programmers simply used it for creating user interfaces or for prototyping.
Version 4.0 introduced a whole new world to Visual Basic programmers. It brought the concept of classes and object-oriented programming, as well as a host of other innovations. Versions 5.0 and 6.0 continued this evolution, although Visual Basic 6.0 added several Internet programming options, as well as the ability to create your own ActiveX DLLs and components.
However, in essence, the Visual Basic language had not changed a great deal since version 1.0. Code written in an older version still ran just fine, even if some of it was now superfluous. VB.NET, however, is a radical departure from past versions of Visual Basic. I must admit that at first I thought this radical shift in programming paradigms would be a very bad mistake, until I got a chance to begin working with VB.NET. I first began working with the public beta version 1.0 and kept up with each successive beta release.
What I saw amazed me. Visual Basic now has all the power and functionality of any other mainstream language including C and Java.
It now has 100% true object orientation, inheritance, and many of the features that have made Java a great language. This book is primarily designed to help a beginning programmer understand VB.NET. It is not assumed that you have any programming experience at all. However, an experienced VB programmer who wishes to become acclimated with the new VB.NET will also find this book useful. Each chapter contains graphics to illustrate what is happening as well asxiiiIntroductionstep-by-step instructions on how to write the code.
The first chapter has you jump right in and develop some simple code. Then we go back and explain the theoretical and conceptual underpinnings. In my experience teaching programming, I have found that students tend to better understand concepts they have seen in action. In this book you will learn the basics of writing VB.NET applications as well as the fundamentals of the.NET architecture. You will also be exposed to some object-oriented theory.
In addition, I will show you how to access databases using ADO.NET, and how to write Internet applications with ASP.NET. By the end of the book you should have a firm grasp of VB.NET. Be sure to download the example files from www.wordware.com/VBNET as they contain fully working applications written in VB.NET. This gives you working examples to use as guides to your studies. The first chapter dives right in and has you writing code. There is also a separate chapter that covers the actual details of the.NET architecture and how this relates to Visual Basic programming. Most of the chapters are concerned with simply showing you how to do things in VB.NET.
However, certain chapters (notably Chapters 4 and 7) delve into the underlying architecture behind VB.NET. Those chapters might be a bit overwhelming for the novice programmer. The good news is that you don’t have to grasp everything in them in order to use VB.NET. If you are a complete novice (new to VB and new to programming) I suggest you read them but don’t worry too much. After about six months of actually working with VB.NET, come back and read them again. There are a couple of items in this book that I don’t think are in any other beginners book. The first is an entire chapter devoted to software design.
There is also a chapter devoted to basic computer science. Many people come to VB from backgrounds other than computer science. These two chapters endeavor to help you “catch up” with some fundamental computer science and software engineering topics.xivChapter 1Windows Applications with VB.NETIn this chapter, you learn about:w Getting started with VB.NETw CommonIntroduction This chapter is designed to introduce you to the essentials of Visual Basic.NET. By the end of this chapter, you should have a basic understanding of developing a Windows application using VB.NET.
This includes the use of forms, components, properties, and events. You should also be getting comfortable with the programming interface and know how to move around in the toolbar, toolbox, and drop-down menus.components and their propertiesw Common programming termsw Drop-down menusw Shortcut keys w Naming conventionsGetting Started with VB.NET When you first launch Visual Basic, you will see the following screen.12Chapter 1 / Windows Applications with VB.NETThis screen is common to all the Visual Studio.NET products. In order to start a new project you will need to go to the drop-down menu at the top of the screen and click on File, New, then Project. You can also accomplish the same thing by pressing Ctrl+N on your keyboard (the Control key and the N key simultaneously).
You will then see the following screen.The first option you see on the left side should be Visual Basic. As I indicated before, this same environment is used for all the Visual Studio.NET products, but for the purposes of this book we will only be concerning ourselves with Visual Basic.NET projects. You will further notice that on theOn this screen you can also choose the name for your project as well as the location in which you place it. At the bottom of this screen you will notice a field called “Name,” and just below that a field called “Location.” You will notice that in our example we have named our project “ExampleOne” and placed it in a folder called “ExamplesChapter One.” Once you have selected the project type, name, and location you will then be able to view the actual development area. This is referred to as the IDE, or integrated development environment.The top of the screen shows the drop-down menus and the toolbar. These contain various functions you will use when programming, such as saving, running, and debugging your program.
There are a lot of interesting and useful features you will need to become familiar with in the IDE, but for the time being we are going to concentrate on getting a few simple VB.NET programs to compile and run successfully.1right-hand side you have several Visual Basic templates to choose from. For this chapter, we will focus on Windows applications; however, later chapters will introduce you to other types of Visual Basic projects.3ChapterChapter 1 / Windows Applications with VB.NET4Chapter 1 / Windows Applications with VB.NETIn the center of the screen you should see a blank form. The form is the cornerstone of Windows applications written with Visual Basic. This is what will be visually displayed to the user of your application.
Beginning with version 1.0 of Visual Basic and continuing through to VB.NET, developers can simply place a variety of components directly on the form, and resize and reposition them. This makes designing the graphical user interface (GUI) much easier. The form itself, as well as all the components you might place on it, have certain properties you can manipulate. They also have events that occur in response to user and system actions. We are going to create a few simple applications that illustrate this point.
If you look on the left side of the screen, you should see a toolbox that displays all the components you initially have available. You have two methods for placing a component on a form. The first is to simply double-click on the component you wish to use in the toolbox. It will then appear in the upper left-hand corner of the currently active form. The second method is to click on the component you wish to add, then drag your mouse on the form, literally drawing the component.
The first example I am going to show you is quite simple but it is a good place to start. If you wish to follow along, you merely need to open Visual Basic.NET, start a new Windows application project, and then follow the steps provided below. Example 1-1For our example, place a single command button on the form, then move the button to the middle of the form.
Then place a single text box directly above it. Your screen should look like the following when you are done.5Chapter1Chapter 1 / Windows Applications with VB.NETIf you look to the lower right side of your screen you should see a window called Properties. If you do not see this, you can click on the form or any components on it and press F4; you should then see the Properties window. This window allows you to set the properties of the form itself or any component on the form. In order to do this, you must first select the individual component in question (by clicking on it), or you can use the drop-down box at the top of the Properties window to select any component on the form. We are first going to set several properties of the command button. The first property we will set is the background color.
For most business applications the standard gray background is perfect; however, I want to illustrate to you what you can do with Visual Basic.NET. When you double-click the BackgroundColor property, you will be presented with three tabs. Select the one called Custom Color. Upon selecting this tab you will be shown a palette of colors. Simply double-clicking on one of the colors will change the command button’s background to the color you choose.
For our example, I am choosing a light blue color. You should note that just below the BackgroundColor property is the BackgroundImage property.
You can use images as the background for the command button, as well as many other components.6Chapter 1 / Windows Applications with VB.NETNext we are going to set the Text property. This property determines what will display as the caption on the button.
We are going to change this to read “Click Me.” Obviously, there are many other properties we could set, and we will examine all of them in time. However, at this point I would like to turn your attention to how to handle user events.
If you doubleclick on the command button, a window will open showing you the code for the button’s Click event.There is a lot of code here that needs to be explained, but first I would like to show you a Windows application in action. With that in mind, we are going to type in a single line of code (the line beginning with “Me.Text”): Private Sub Button1Click(ByVal Sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click Me.Text = TextBox1.Text End SubIn order to see what our application does, you must run the program. You can do this by using any of the following methods: nPress the F5 key.nPress the arrow-shaped button on the toolbar (it looks like a play button on a CD player).Select Debug Start from the drop-down menu at the top of the IDE.Whichever method you choose, when you run the example you will see a screen with our command button and our text box located on it. If you then type some text in the text box and click the command button, you will find that the caption for the form is changed to the text you put in the text box.This simple application illustrates many of the basic principles of Visual Basic.NET. The first thing you should notice is that you can easily place any components you wish on a form and design a user interface.
The next thing you should notice is that when you are developing your application (referred to as “design time”) you can change the properties of any component you wish using the Properties window. Finally, you should notice that when your application is running (referred to as “run time”) you can have your code written in such a way that it changes the properties of various components.
In our single line of code we did two very interesting things. First, we extracted the value contained in the Text property of the text box, then we placed that value into the Text property of the form (the “Me” keyword refers to the current form you are working with). All of this was accomplished in response to a user clicking the command button.1n7ChapterChapter 1 / Windows Applications with VB.NET8Chapter 1 / Windows Applications with VB.NETAt this point a bit more explanation of an event is in order. When you write code in any programming language (be it Visual Basic, C, Java, Perl, etc.), you don’t simply write line after line of code. You usually organize the code into logical sections that perform some action. These sections are referred to as functions or subroutines. Basically, when you place a section of code in one place with a common name to refer to that section of code, you have a function.
For example, if I wish to write a function that divides two numbers, I might write something like this: Public Sub Divide(Num1 as Single, Num2 as Single) Dim Answer as Single Answer = Num1 / Num2 End SubThe first line of this code is referred to as the function declaration line. It contains several elements, namely the access modifier (whether it is public or private), the word “sub,” the name you wish to give your function, and any parameters you want to pass to your function. An event is simply a function, usually connected with some component, that is called in response to some user or system action.
One example is the Click event, which is a function that is called when the user clicks on a button. You will find that a great deal of Visual Basic code is concerned with manipulating the properties of components and responding to events. Before I begin a more detailed examination of what is occurring, I would like to show you one more example.
Example 1-2 1.Start a new project as a Windows application.2.Place one text box and four labels on the form. Set the labels’ Text properties to blank and the BorderStyle to Fixed3D.3.Place one command button on the form.4.Change your form’s caption to read String Stuff.
Now your form should look like this:9Chapter1Chapter 1 / Windows Applications with VB.NET5.In the Click event of the command button place the following code: Dim MyString as String MyString = Textbox1.Text Label1.Text = Ucase(MyString) 'display uppercase version of the string Label2.Text = Lcase(MyString) 'display lowercase version of the string Label3.Text = Len(MyString) 'display length of the stringRemember that the way you access the Click event is to double-click on the command button. 6.Using one of the procedures explained earlier in this chapter, run the application.7.When the application is running, type your first name into the text box and press the command button. You will see something like the following image.10Chapter 1 / Windows Applications with VB.NETThis second example has you once again manipulating the properties of text boxes and labels, both at design time and run time. It also has you returning to the Click event of the command button. The text box, label, and command button are perhaps the most ubiquitous components in Visual Basic, so it behooves us to begin our examinations with them. Now that you have seen some simple Windows applications work in VB.NET, it is time for us to go back and examine that cryptic looking code we saw when we looked in the Click event of our command button. To refresh your memory, what you should have seen would be something like this: Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Button1Click(ByVal Sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click End Sub End ClassThe first thing you may notice is the Public Class Form1 line.
You might be asking what that means. Let me explain. VB.NET has implemented a purely object-oriented paradigm (unlike previous versions of Visual Basic). What this means is that all the forms (as well as most other portions of your Visual Basic application) are really made from classes. A class is simply a code template for creating an object.
Every component you put on a form (and, incidentally, the form itself) is an object. When you change the placement of a text box on a form and change one of its properties, what you have actually done is created an instance of the textbox object and changed one of its members.I will go into more depth on object-oriented theory and practice in a later chapter, but for the time being it is simply necessary for you to realize that a class is a template for creating an object, and that an object has properties and methods. So what our code example is telling us is that there is a class called “Form1” and one of the methods for that class is our button1 Click event. It is also telling us that this event takes several parameters (that are passed by the system; you don’t have to write code for them). You don’t have to do anything with parameters that are passed to your function or event if you don’t wish to. In our case, we did not.Common Components and Their Properties You have already seen how easy it is to create the user interface using the components that Visual Basic.NET provides you with. There are many components you can utilize in your applications.
In this section, I will describe to you, in brief, some of the most commonly used components, what they are used for, and their most important properties. I should note here that you will often hear the words “component” and “control” used interchangeably. Don’t let this confuse you.
Some components are used more often than others. The form is the most basic component. It is the container in which you place all the other components.
It is also what your user will see. The most important properties you will set for a form are its name (what the computer will call it), its text (what appears in the title bar that the user will see), and its back color (what color you want the background to be). You may also wish to set its border style (this determines if it can be resized by the user or not). Below are listed some other common components and the properties you will be most concerned with.Components Text Box This component allows the end user to enter data.
You will want to set its name (what the computer will call it), its text (the default text that initially appears when you run the program), and possibly its font if you wish a different font in the text box. You can also enter something into the Text property as a default text. Finally, you may want to set its max length111ChapterChapter 1 / Windows Applications with VB.NET12Chapter 1 / Windows Applications with VB.NETproperty. This determines the maximum number of characters a user can type into the text box. You can also set its password character property to show a symbol in lieu of the actual password. The multiline and scroll bar properties allow you to have a text box that can handle several lines of text.Label Labels are used to display information to the end user, but the end user cannot change any information in the label. The properties you set in this component are the name (what the computer will call it), its text (what the user will see), and its font.Command Button Command buttons allow the user to click a button.
A lot of the code that you write will be associated with command buttons. The properties you are most interested in are its name (what the computer will call it), its text (what the user will see), its style (whether your button will have a text caption or a picture), and its font.List Box A list box simply allows you to list items from which a user can choose. The property you are concerned with is the font. The items are listed using code and will be discussed later.Combo Box This is like a list box but you can set more options.Picture Box Using this component, you can place any bitmap (.bmp), Windows metafile (.wmf), or icon (.ico) on your form. Starting with Visual Basic version 5.0, you can also add in JPEG (.jpg) and GIF (.gif) image files. All you do is set the stretch property to true (this ensures that the picture you insert will be the size of your picture box) and then use the picture property to select the picture you want to use.Group Box A frame is basically a container component. It is used to group other components.
The property you will use most with it is its caption.113ChapterChapter 1 / Windows Applications with VB.NET14Chapter 1 / Windows Applications with VB.NETComponent Properties Font Many components have a font property that lets you select the font for that component. Below is what you will see if you select the font property of any component:Using this screen you can easily change the font settings for most components. A lot of the programming you do will be concerned with using code to alter the properties of some component. To do this, you write the component name you wish to alter followed by a period and the name of the property you want to change. The syntax for this is: ComponentName.Property = “whatever”Some specific examples are: Textbox1.Text = “Howdy” Me.Text = “This is my form” Picturebox1.Image = “c:folderimage.bmp” Label1.Text = “This is a label”Tip: If your code referencing a property does not work, it is most likely because you misspelled either the component or property name.Using this basic technique, you can write code to change the properties of any component you wish.
This is important to remember since much of the code you write in Visual Basic is concerned with altering the properties of various components. Example 1-3Let’s try one more example to illustrate the use of components and properties. Start up a new Windows application. I will call mine example3. Now, on that form place one list box, one text box, and one command button. In the Properties window (either select View Properties or press the F4 key) change the command button’s caption to Add Text.
Your form should look like the image below.If you double-click on the command button you will get its code window. This will show you the Click event, just as we saw in the previous two examples.115ChapterChapter 1 / Windows Applications with VB.NET16Chapter 1 / Windows Applications with VB.NETIn it place this code: ListBox1.Items.Add(TextBox1.Text)Run your program. Remember that you can do this by clicking on the Run button in the toolbar or by pressing the F5 key. Now every time you click on the command button, whatever you have typed into the text box will be added to the list box!Common Programming Terms The following is a list of standard Visual Basic and programming terms that you will need to be familiar with. In programming, proper nomenclature (or naming) is vital. You cannot understand instructions or communicate with other programmers without an understanding of proper nomenclature. ApplicationA fancy word for the program you write.BugAn error in your program.CodeThe actual program instructions that you write.Code moduleA module of separate subroutines completely separate from a form.CompileThe process of taking your source code and creating an executable program from it.ComponentsThe various objects that Visual Basic has for you to use in your graphical user interface.
Examples are the text box, command button, list box, combo box, and picture box. Many Visual Basic books call these components “controls.” That was the name used in previous versions of Visual Basic.DebugTo remove errors in your program.EventA function that responds to an action taken by the user or the system itself. The Click event is a good example.FormThe component on which you place other components and design the user interface.FunctionA group of related statements that perform some action.IDEIntegrated development environment.ProjectWhat contains all the files in your program. It includes forms, code modules, class modules, etc.
In Visual Basic.NET this idea has been expanded to the notion of the assembly, which also includes information about all the other items, such as DLLs, that your application may depend on.StatementA single line of code that performs an action.117ChapterChapter 1 / Windows Applications with VB.NET18Chapter 1 / Windows Applications with VB.NETSubroutineA subsection of code. Events are premade subroutines in Visual Basic.VariableA place in memory set aside to hold data of a particular type.The Drop-Down Menu The drop-down menu gives you access to several possible functions. The following is a list of the main drop-down options you see at the top of your screen and several of the suboptions along with their functions.
I do not cover all the drop-down menu options here, only the ones that you as a beginner need. We will cover others later in this book.File New ProjectOpens a new blank project for you to begin working with.Open ProjectAllows you to open an existing project.
When you select this option, you will see a dialog box that you can use to browse your computer to find the project.CloseCloses the currently open project.Save AllSaves changes made to all the modules in your project.Save FormSaves the specific form that currently has focus.Save Form As Allows you to save a specific form under a name of your choosing and in the folder/directory that you select. ExitExits Visual BasicUndoAllows you to undo whatever action you last performed.EditTip: The Undo option exists in most Windows programs. If you do something you wish you hadn’t done, don’t panic; simply select “Undo.”RedoAllows you to redo the last action performed or the action on which you used Undo.Removes the code or component you have selected and places it on the clipboard. You can also use the shortcut keys Ctrl+X to accomplish this task.CopyPlaces a copy of the code or component you have selected on the clipboard. You can also use the shortcut keys Ctrl+C to accomplish this task.PasteInserts something that you have previously copied or cut.
You can also use the shortcut keys Ctrl+V to accomplish this task.View Tip: I always hear at least one student in panic yelling “I can’t find my project/form/code module/etc.” The solution to this problem is usually to go to View and select that object.CodeDisplays the underlying code for any object that currently has focus.DesignerAllows you to view the object of the code you are currently viewing.Solution ExplorerDisplays a window containing a listing of all files in your project.Properties WindowDisplays the Properties window. It will usually appear to the right of the IDE. You can get to it by selecting View Properties or by pressing F4. It will display the properties of whatever component currently has focus.Tool BoxYou can use this to make your toolbox visible.
The toolbox contains all the components you might use in your project. This is usually on the left side of the IDE.Project Add Windows Adds a new form to your project. When you select Form this, you will be prompted as to what type of form you wish to add. You will usually select the Windows Form option, but Visual Basic has a number of premade forms you may want to use.1Cut19ChapterChapter 1 / Windows Applications with VB.NET20Chapter 1 / Windows Applications with VB.NETAdd ModuleAdds a blank code module.Add ClassAdds a class module.Add ComponentAdds new components to your toolbox so that you can use them in your project.
Visual Basic has many more components than you see in your toolbox. This option lets you select which components you want to be visible.
If you select this option you will see a window like the one below from which you can choose the components you want available for your project.Build This menu gives you a variety of options for compiling your project. This will be discussed in depth in later chapters.Debug This menu gives you a variety of options for finding bugs in your program, and we will discuss them at some length later in this book. For now, the only option under this menu you should be concerned with is the Start option.
It simply causes your program to run.Chapter 1 / Windows Applications with VB.NET21The following are a few of the most commonly used shortcut keys. You may want to memorize them. F3FindF4View an object’s Properties windowF5RunF7View the Code window of an objectCtrl+ZUndoCtrl+CCopyCtrl+XCutCtrl+VPasteNaming Conventions Microsoft has established some naming conventions that you should use when naming components. This makes for more uniform code that is easy to read. By default, each of your components will have a name like: text1, label1, command4, etc. You must go to the Name property of each component to change its name.
Naming conventions simply make it much easier for another programmer to see what you are doing. Following are some examples of Microsoft naming conventions: Component TypeNaming ConventionText BoxTxtWhateverButtonBtnWhateverLabelLblWhateverPanelPnlWhateverFrameFraWhateverCombo boxCmboWhateverList boxLstWhateverUsing these naming conventions will make reading your code much easier.
I realize that it is even easier and faster to just leave your components with the default name. While you are working on simple projects it won’t really matter, but when you have to work on real-world applications, youChapter1Shortcut Keys22Chapter 1 / Windows Applications with VB.NETdon’t really want to spend time trying to figure out that Text1 refers to the account number.Summary The purpose of this chapter was to give you a jump start on learning Visual Basic.NET.
I wanted to introduce you to the IDE as well as common programming terms and concepts. You were also given the opportunity to begin actually writing some simple Windows applications using VB.NET. VB.Net is cool!Now, I will be the first to admit that this is very trivial.
However, this simple example illustrates some important points about VB.NET’s Web development capabilities. To begin, with you can write HTML code, including server-side components, without knowing much about HTML (for more details on HTML, see Appendix D). Even if you don’t understand any of the HTML code this example generated, you can still write Web applications. In my opinion this is one of the most useful features of VB.NET, though I would still recommend you acquire at least a cursory knowledge of HTML. The other point this example should have illustrated to you is that the HTML components can be manipulated via properties in much the same way as standard Windows components. With that in mind, I would like to introduce you to the most commonly used HTML components and explain their properties.HTML Components Button The HTML button is used in much the same way as a standard Windows Forms button.
You click it to have some action take place. In HTML, the possible actions are more limited than in a Windows form and the properties you can set are also somewhat limited.
Media skins:Media Control. All in one Media Control with 3 different skins changeable via the context menu. Simple Media Control:.
Uses media-key-strokes to control the current local media player (works out of the box with more or less all local players). Local Media Control:. Shows metadata from a local media player and the cover-image if available, hover the skin to reveal the controls. The used player has to be set in the settings skin!. Shows up to 20 HWiNFO sensors ( required!) (Screenshot: ). All sensors can be easily reconfigured through the Shared Memory Viewer (HowTo: ). They are predefined for all kind of sensors a current AMD Ryzen system offers but all can be completely changed to whatever sensor HWiNFO returns.
The displayed name can be customized for each sensor individually or leave the name-variable blank to use the sensor-name returned by HWiNFO. All colors can be customized. Hover the sensor to show the minimum, maximum and average values. Shows a ping monitor for up to 5 destinations which works with any address/IP.
Downtime counter, average measuring and max latency values. Additional skin accessible via the context menu for Ping with DNSlookup (but doesn't work with local stuff) (Screenshot: ). Uses the API from hackertarget.com (100 requests per day). Tries to parse the A-Record from the DNSlookup and uses this IP as destination. Hover the address to see the pinged IP.
Click the Mag-glass icon to open the DNSlookup of this address. Market skins:Cryptocurrencies. Shows up to 10 cryptocurrencies fetched from. Combine whichever crypto currency you want (ex: btc to usd, btc to eth, eur to grc.).
Shows icons for From-/To-Currency. Shows the ranking next to the name. Color-change on rise/fall. As an alternative there's a second skin available via the context menu which fetches the cryptocurrencies from.Their current API-v2 will be taken offline and the new one requires a API-Key.
Hey,I'm glad you like my collection!1) Yes this is definitely possible but would take some time to do, maybe I'll add that to my ToDo list.2) And a Yes to this.Here's the howto for, I think, the fastest way to do this:1. Go to 'C:Users-USERNAME-DocumentsRainmeterSkinsGadgets Additions Variables'2. Make a copy of the file 'MediaControl.inc' and name it 'MediaControl2.inc'3. Go to 'C:Users-USERNAME-DocumentsRainmeterSkinsGadgets Additions'4. Make a copy the folder 'Media Control' and name it 'Media Control2'5. Open this new folder and change '#@MediaControl.inc' to '#@MediaControl 2.inc' in the top of each file6.
Restart Rainmeter7. Glad you like my pack!Thanks for the info about the typo.Only because my skins support more entries (wannabe responsive) and I've forgot to block you to enter more then five in the settings skin, that doesn't mean I felt the need for including more of them.No one complained, so nothing was added. But ok now I have my complain and I'll add modified skins (currencies, cryptocurrencies and stocks) in the next version which support 10 entries too.One notice:Please do NOT mirror my suite on other sites. Glad you like our Gadgets!I've took a look at this skin and this time the modification is even easier.Add the following block above the meter MeterBackground:MeasureFrostedGlassMeasure= PluginPlugin=FrostedGlassType=BlurBorder=NoneRefresh the skin (right click and refresh).Go to the settings of this skin (arrow icon and then gear icon) and change the following:Background = 1Reflection = 1Shade = 1Shine = 1Blur = 0The gap on this skin is a little bit bigger than on mine or SilverAzides ones but this would need probably many more modifications to fix.