Programming Tutorials

VB.net Tutorials

31. Creating List Views in Code using VB.net

By: Steven Holzner : 2009-03-22

Description: You can add items to list views in code. In this case, when the form loads, I'll add four items to a list view. As you might expect, you do this with the Add method of the list view's Items collection, which can take the text of the new item and an image index in an ImageList for an icon to display for the item.


32. Creating Tree Views in Code using VB.net

By: Steven Holzner : 2009-03-22

Description: You can create tree views in code as well as at design time. The trick here is realizing that the hierarchical nature of tree views means that one node's Nodes collection can contain child nodes, which can itself contain child nodes, and so on, so you can refer to nodes using syntax like MyNode.Nodes(3). Nodes(5). To add a new node, you use the Nodes collection's Add method. Like other controls, you can use the BeginUpdate and EndUpdate methods to turn off updating of the tree view while you're updating it. Note that this example uses the Clear method to clear all nodes in the tree view before refilling it. (Note also that I'm using a few advanced programming techniques here, such as creating our own classes and storing objects in an ArrayList collection.) Here's the code, showing how to stock a tree view with nodes, and how to give those nodes child nodes, and so on, at run time


33. Creating Context Menus in Code using VB.net

By: Steven Holzner : 2009-03-22

Description: Creating context menus is much like creating standard menus - you only need to add a ContextMenu control to a Windows form. The caption for this context menu is simply "Context Menu", but everything else is the same as creating any standard menu - just give the items in the menu the captions you want


34. Creating Menus in Code using VB.net

By: Emiley J. : 2009-03-22

Description: This example creates a menu system - all you really have to do is to create MenuItem objects and use the MenuItems collection's Add method to add them to menus or other menu items


35. Handling Timer Events - and Creating an Alarm Clock in VB.net

By: Steven Holzner : 2009-03-22

Description: To get an idea how timers work, I'll create an example alarm clock, called Timers. Here, the user can click the "Start clock" button to start the clock, which is displayed in a label control. (I've set the font of the label at design time to use a large font face). The clock's display is updated once a second in the timer in this example, Timer1. I've set the timer's Interval property to 1000 milliseconds, or one second, which means its Tick event occurs every second. I update the label's text like this in the Tick event handler: Label1.Text = TimeOfDay (the TimeOfDay property returns a DateTime object with the current time).


36. Send SMS using VB code

By: Emiley J : 2009-03-16

Description: If you are looking for a simple program to send SMS from your PC using VB then here is the code.


37. Creating a Windows Service Installer in VB.net

By: Steven Holzner : 2009-02-27

Description: After you've created a Windows service, you need an installer. Here's the code for the installer in the WindowsService example, Project Installer.vb:


38. Creating a Windows Service in VB.net

By: Steven Holzner : 2009-02-27

Description: You can create a new Windows service easily in Visual Basic - just use the File-New-Project menu item, select the Windows Service icon in the templates box, and click OK. Here's the code for that Windows service, Service1.vb:


39. OleDbConnection class in VB.net

By: Steven Holzner : 2009-02-24

Description: An OleDbConnection object supports a connection to an OLE DB data provider. In practice, you usually use OLE DB connections with all data providers except Microsoft's SQL Server. Note that, depending on the OLE DB data provider, not all properties of an OleDbConnection object may be supported.


40. OleDbDataAdapter class in VB.net

By: Steven Holzner : 2009-02-24

Description: OleDbDataAdapter objects act as a bridge between datasets and data sources. As you know, datasets are really just repositories of data; they're not directly connected to a database. OleDbDataAdapter objects connect datasets and data sources by supporting the Fill method to load data from the data source into the dataset, and the Update method to send changes you've made in the dataset back to the data source.