Visual Basic 2010 Source Code Samples

C# / .NET Code Samples
Visual basic sample projects

Hello cybernick75 Appreciatted you share this source code with us, free of sny charge. I can imagine how long you spent creating such a project. But I have to say it is incomplete because i ding came with a db or a DB Script. If You send the db script I create your project on. 101 Code Samples for Visual Basic; for Database There is no Visual Basic Database, the sample gives you code how to access databases with Visual Basic for Net. Those databases have their own script mostly SQL transact code.

DotNetResourcesExtract v1.00
DotNetResourcesExtract is a small utility that scan dll/exe files of .NET applications, and extract all .NET embedded resources (Bitmaps, Gifs, HTML files, and so on) stored in them into the folder that you specify.
Visual C++ Code Samples And Utilities
Source

Visual Basic Sample Programs

Source Code Samples
Changing the screen brightness programmingly - By using the Gamma Ramp API
Some video cards allows you to programmingly modify the Gamma Ramp values.You can use this feature to change the brightness of the entire screen.
Preventing application crash by using exception handling mechanism
When a program does something wrong, for example, reading from invalid memory address,the operating system displays a 'crash' window with information about the problem that caused the exception,and terminates the application. This sample project demonstrates how to avoidthis kind of crashes, display your own exception information window,and allow the user to continue running the application after the exception occurred.
Moving items up and down in a ListView control.
In some occasions, you might want to allow the user the change the order of items in the ListView, by moving the selected items up and down. In the API of ListView control, there is no support for swapping between 2 items. The only way to do that, is by manually swapping all data of the items, including the lParam value and all columns !
Displaying 'Browse Folders' dialog with the default folder selected.
The 'Browse For Folder' dialog allows the user to select a folder from all available local drives and network resources. This code snippet demonstrate how to display this dialog-box.
Displaying the 'Properties' of a file or folder.
When you select a file or folder in Explorer window, and choose 'Properties' from the menu, you get the properties window that contains some essential information about the file: The size of file, created date, modified date, attributes, and so on.It's possible to display this properties window programmatically, by using the ShellExecuteEx API function.
Enumerating Windows credentials with CredEnumerate function
This code sample enumerates all credentials of the current logged on user,and dump them into the standard output.
Utilities With Full Source Code
Visual basic 2010 source code samples pdf
ExeInfo v1.01
The ExeInfo utility shows general information about executable files (*.exe), dynamic-link libraries (*.dll),ocx files, and drivers files.
AtNow v1.1
AtNow is a command-line utility that schedules programs and commands to run in the near future.
WinExplorer v1.30
WinExplorer is a utility that shows all system's windows in hierarchical display.
For every window in the hierarchy, you can view its properties, like handle, class name, caption, size, position and more. You can also modify some properties, like Caption and Visible/Enable.
Visual Basic Code Snippets and Utilities

In the following section, you can find a variety of Visual Basic code samples. For every sample, you can download the entire project for opening in Visual Basic 6.0.

Revealing the passwords behind asterisks in Internet Explorer
This small utility reveals the passwords stored behind the asterisks in the web pages of Internet Explorer 5.0 and above.
Creating a real console application in Visual Basic !
Although the Visual Basic compiler doesn't allow officially to create console applications, it's possible to do it with a simple trick.
Read more >>
Revealing the passwords behind asterisks
This code snippet scans all opened windows, and reveals the passwordsbehind the password text-boxes.
Access 95/97 Password Revealer
This small utility reveals the database password of Microsoft Access files.
It works only with version 95 and 97 of Microsoft Access.
System resources in Windows 95/98
This code snippet shows the percentages of free system resources in Windows 95 and Windows 98.
Fast string concatenation
With this class, you can concatenate small strings into one big string in faster way than the standard '&' operator.
Using bidi32.dll for Logical-Visual conversion
This code snippet is designated for using in bidirectional systems only (Hebrew and Arabic).
It uses the functions in bidi32.dll to convert strings from Visual to Logical and from Logical to Visual.
Painting a Gradient between 2 colors on a form
This code snippet shows how to paint a gradient on a form using Win32 API.
Drawing a rotated text on a form
This code snippet demonstrate how to draw a rotated text on a form.
Creating a circle shaped window
This code snippet demonstrates how to create a circle shaped window, by using a few Win32 API calls.
Web client tester
With this small utility, you can send HTTP queries and see how the servers responds to those queries.
Faster items adding in ComboBox
This code snippet shows you how to add combo items with Win32 API. It's much faster than using the AddItem method of VB.
Faster items adding in ComboBox (with item data)
This code snippet shows you how to add combo items (both strings and items data) with Win32 API. It's much faster than using the AddItem method of VB.
Executing Control Panel applets
This code snippet shows how to run standard Control Panel applets (Display Properties, Reginal Settings, Mouse Properties, and more)from Visual Basic code.
Converting network drive-based path to universal path name
This code snippet shows how to use the WNetGetUniversalName for convertingnetwork drive-based path (Like I:windows) to universal path name (Like MyComputercwindows)
Opening special Explorer windows
This code snippet shows you how to open special Explorer windows, like My Computer, Control Panel, Printers, Fonts and more...
DoEvents alternative function
This code snippet shows how to create an alternative function for the standard DoEvents function.
Registering and using a new window class
This code snippet shows you how to register a new window class in Visual Basic anduse that class to create new windows, and show them on a form.
Displaying and using a dialog box from external DLL file
This code sample shows you how to display a dialog box from external DLL file.In this sample, the standard 'Run' dialog of Microsoft Windows is shown on the screen.
Displaying the 'Shut Down Windows' dialog
This code snippet displays the 'Shut Down Windows' by using undocumented API in shell32.dll
Getting the filename of an ActiveX class name

In the previous Lesson, you have learned that Visual Basic 2010 is an object oriented programming language. You have understood the meanings of class, object, encapsulation inheritance as well as polymorphism. You have also learned to write some simple programs without much understanding some underlying foundations and theories. In this Lesson, you will learn some basic theories about VB2010 programming but we will focus more on learning by doing, i.e. learning by writing programs .I will keep the theories short so that it would not be too difficult for beginners.

5.1 The event Procedure

Code

Visual Basic 2010 is also an event driven programming language. Event driven means the user will decide what to do with the program, whether he/she wants to click the command button, or he/she wants to enter text in a text box, or he/she might wants to close the application and etc. An event is related to an object, it is an incident that happens to the object due to the action of the user , such as a click or pressing a key on the keyboard.

A class has events as it creates an instant of a class or an object. When we start a windows application in VB2010 in previous chapters, we will see a default form with the Form1 appears in the IDE, it is actually the Form1 Class that inherits from the Form class System.Windows.Forms.Form, as shown in the Form1 properties window in Figure 5.1.

When we click on any part of the form, we will see the code window as shown in Figure 5.2. The is the structure of an event procedure. In this case, the event procedure is to load Form1 and it starts with Private Sub and end with End Sub. This procedure includes the Form1 class and the Load event, and they are bind together with an underscore, i.e. Form_Load. It does nothing other than loading an empty form. You don't have to worry the rest of the stuff at the moment, they will be explained in later Lessons.

Visual basic source code

In addition, there are other events associated with the Form1 class. These events are click, cursorChanged, DoubleClick, DragDrop, Enter and so on, as shown in Figure 5.2(It appears when you click on the upper right pane of the code window)

Figure 5.2 The Events

5.2 Writing the code

Now you are ready to write the code for the event procedure so that it will do something more than loading a blank form. The code must be entered between Private Sub.......End Sub. Let's enter the following code :

The first line of the code will change the title of the form to My First VB2010 Program, the second line will change the foreground object to Forest Green( in this case, it is a label that you insert into the form and change its name to Foreground) and the last line changes the background to Csyan color. The equal in the code actually is used to assign something to the object, like assigning yellow color to the foreground of the Form1 object (or an instance of Form1). Me is the name given to the Form1 class. We can also call those lines as Statements. So, the actions of the program will depend on the statements entered by the porgrammer.

The output is shown in the Figure 5.3

Figure 5.3

Visual Basic 2010 Code Samples

Here is another example:

In this example, you insert one command button into the form and rename its caption as Show Hidden Names. The keyword Dim is to declare variables name1, name2 and name3 as string, which means they can only handle text. The function MsgBox is to display the names in a message box that are joined together by the '&' signs. The output is as shown in Figure 5.4

Visual Basic Sample Projects

Figure 5.4