O w n e r
Let's Shared

Senin, 16 Maret 2009

Add Items to the Toolbox

To add items from your computer

  1. On the Tools menu, click Choose Toolbox Items.

  2. Click Browse.

    The Open dialog box appears.

  3. In the My Places Bar, select My Computer to browse for items installed on your computer drives.

    —or—

    In Look in, select My Network Places to browse for items located on a network share.

  4. Click OK.

More...

Using the Toolbox

The Toolbox is a sliding tree control that behaves much like Windows Explorer, but without grid or connection lines. Multiple segments of the Toolbox (called "tabs") can be expanded simultaneously, and the entire tree scrolls inside the Toolbox window. To expand any tab of the Toolbox, click the plus (+) sign next to its name. To collapse an expanded tab, click the minus (-) sign next to its name.
The Toolbox displays icons for items that you can add to projects. Each time you return to an editor or designer, the Toolbox automatically scrolls to the tab and item most recently selected. As you shift focus to a different editor or designer or to a different project, the current selection in the Toolbox shifts with you.

Manage the Toolbox Window

To open the Toolbox

On the View menu, select Toolbox.
For the following procedures, make sure that the Toolbox has focus.
To conceal the Toolbox
On the Window menu, select Hide.
To reopen the Toolbox, select Toolbox from the View menu.

To make the Toolbox close automatically
On the Window menu, select Auto Hide.
To make the Toolbox remain open
On the Window menu, clear Auto Hide.
To move the Toolbox to a different location
- On the Window menu, clear Auto Hide, and then select Floating.
- Drag the Toolbox to the desired location.

To dock the Toolbox
- Open the Toolbox.
- On the Window menu, clear Auto Hide, then select Dockable.
- When docking arrows appear, select the arrow that points toward the edge of the parent frame
where you want to attach the Toolbox.

To display the Toolbox as a tabbed editing window
- Open the Toolbox.
- On the Window menu, clear Auto Hide, then select Tabbed Document.

To restore the Toolbox from a tabbed document state to a docked window state, right-click on the window tab and select Dockable from its shortcut menu.
To restore all default tabs to the Toolbox, with their default icons
Right-click on the Toolbox and choose Reset Toolbox from its shortcut menu.

To expand a Toolbox tab
Select the plus (+) sign next to the name of the closed Toolbox tab.

To conceal a Toolbox tab
Select the minus (-) sign next to the name of the expanded Toolbox tab.

To change the position of a Toolbox tab
Right-click on the name of the tab and choose Move Down or Move Up from its shortcut menu. 0r Drag the tab to the desired position in the Toolbox, and release the mouse.

To rename a Toolbox tab
- In the Toolbox, right-click the desired tab, then choose Rename Tab from its shortcut menu.
- In the text box at the top of the tab, type a new name for the tab and press ENTER.

To add a custom Toolbox tab
- Right-click on the Toolbox and choose Add Tab from its shortcut menu.

A new blank tab is added to the Toolbox.
- In the text box at the top of the new tab, type a name for the tab and press ENTER.
The new tab appears at the bottom of the Toolbox. You can then position the new tab and add items to it.
Tip:

Use custom tabs to store icons for preconfigured controls.
To remove a custom Toolbox tab
1. Drag any icons you are still using to other Toolbox tabs.
2. Right-click the Toolbox tab you no longer want, and choose Delete Tab.
If any items are left on the tab, a message box informs you that those items will be deleted.
3. Select OK to delete the selected tab from the Toolbox.

To display all available Toolbox tabs, regardless of context
Right-click on the Toolbox and choose Show All from its shortcut menu.

After running this command, you will need to recreate any custom tabs, and add icons for the desired items to them.

Toolbox Item Procedures

To insert a Toolbox item at the selected location on the active designer
Double-click the desired item on the expanded Toolbox tab.

To store text or code in the Toolbox
1. In the editor or designer, write the text or reconfigure the control to be reused.
2. Select the desired text or code, and drag the selection onto the desired Toolbox tab.
A line marks the position on the expanded tab where the new Toolbox icon will be created.
3. Rename the new Toolbox icon as you wish.

For example, you might insert a standard Button control, define its style as you prefer, and then store this preconfigured code as a custom button template on the desired Toolbox tab.
To rename an item on a Toolbox tab
1. In the Toolbox, right-click the desired item and choose Rename Item.
2. In the text box, type a new name for the item, and then press ENTER.
To sort the items on a Toolbox tab alphabetically
In the Toolbox, right-click the desired tab, and then choose Sort Items Alphabetically.

Items that cannot be moved are copied instead.
To copy an item from one Toolbox tab to another
Press the CTRL key and drag the item from the expanded Toolbox tab onto another tab.

Copy the item and Paste it onto the name of the desired tab.

To add and remove items from the Toolbox
1. On the Tools menu, click Choose Toolbox Items.
The Choose Toolbox Items dialog box is displayed.
2. In the Choose Toolbox Items dialog box, click from tab to tab to browse through available categories of Toolbox items.
3. If you do not see an item that you need, click Browse to add items to the Choose Toolbox Items dialog box.
4. Select any items you wish to add, and deselect those you wish to remove.
5. Click OK.

Icons for items selected in Choose Toolbox Items are now available in the Toolbox. You can drag any items added to the current tab to other tabs. Icons for items deselected in Choose Toolbox Items will no longer appear in the Toolbox.

More...

Error handling in Visual Basic .NET

Visual Basic .NET or Visual Basic 2005 supports two different ways to keep an unexpected error from terminating an application: unstructured error handling and structured error handling. These events are run-time errors--also called exceptions-- that are responses to abnormal or exceptional conditions that are caused by the execution of a block of code.

Unstructured error handling is the name that is used in Visual Basic .NET or Visual Basic 2005 to refer to the error handling method that is used in Microsoft Visual Basic 6.0. Structured error handling is introduced for the first time to Visual Basic programmers in .NET and is performed by using the Try...Catch...Finally statement, which has long been a feature of other programming languages. Structured error handling introduces a simpler way to create and maintain programs with robust, comprehensive error handlers.

Although Visual Basic .NET Visual Basic 2005 supports both methods, the methods cannot be implemented simultaneously in the same procedure. The only exception to this is the Error statement, which can be used in structured error handling. It is recommended that all error handling in Visual Basic .NET or Visual Basic 2005 be performed with structured error handling. Unstructured error handling can degrade the performance of the application and result in code that is difficult to debug and maintain.

In the case of a run-time error, both error handling methods look for a local error handler that is defined in a particular block of code. If no local error handler is present, the exception is propagated up the call stack, until a matching handler is found. The call stack represents all procedures that have been called prior to the current point of execution and have not yet been terminated. If no handler is found in the procedures in the call stack when an error occurs, the application is terminated.

Unstructured Error Handling

Unstructured error handling is implemented with the On Error statement, which is placed at the beginning of a code block to handle all possible exceptions that occur during the execution of the code. All Visual Basic 6.0 error handlers in .NET are objects that can be accessed by using the Microsoft.VisualBasic.Information.Err namespace. The handler is set to Nothing each time the procedure is called. You should place only one On Error statement in each procedure, because additional statements disable all previous handlers that are defined in that procedure.

On Error Statement

The On Error statement is used to enable an error-handling routine, disable an error handling routine, or specify where to branch the code in the event of an error.
   On Error { GoTo [ line | 0 | -1 ] | Resume Next }
GoTo line

Used to enable the error-handling routine, starting at the location that is specified by the line argument. The line argument can be either a line label or a line number that is located within the closing procedure. A run-time error activates the error handler and branches the control to the specified line. If the specified line is not located within the same procedure as the On Error statement, a compile error occurs.

To avoid unexpected behavior, place an Exit Sub statement, an Exit Function statement, or an Exit Property statement just before the line label or line number. This prevents the error-handling code from running when no error has occurred.

GoTo 0

Disables the enabled error handler that is defined within the current procedure and resets it to Nothing.

GoTo -1

Disables the enabled exception that is defined within the current procedure and resets it to Nothing.

Resume Next

Moves the control of execution to the statement that follows immediately after the statement that caused the run-time error to occur, and continues the execution from this point forward. This is the preferred form to use to access objects, rather than using the On Error GoTo statement.

Example

In the following example code, the error handler is enabled on the first line of the routine with the On Error GoTo Unstructured statement. The location of the error handling routine is identified with the Unstructured line label. The error routine implements a simple Select Case statement that executes the corresponding block of code, depending on the error that occurred.

The Resume Next statement at the end of the error handling procedure returns control of the execution back to the line that follows the line that caused the error to occur.

The error handler is then disabled with the On Error GoTo 0 statement, followed by the On Error Resume Next statement, which reactivates the error handler. If a run-time error occurs, the statement causes the execution to branch to the line that immediately follows the line that caused the error to occur, the same way that the Resume Next statement does in the error handling routine. In this case, that line is the If statement that evaluates the error number and displays it to the user, as well as clearing the error object.



Public Sub fnErrors()

On Error GoTo Unstructured ' Enable error handler

Dim Result As Integer
Dim Value1 As Integer = 9
Dim Value2 As Integer = 0

On Error GoTo 0 ' Disables the error handler

'Moves execution to the line following the line that caused the error.
On Error Resume Next

Result = Value1 / Value2 ' Division by zero, cause an overflow error.

' Catch the overflow error caused by dividing by zero.
If Err.Number = 6 Then
MessageBox.Show("Error Number: " & Err.Number.ToString)
Err.Clear() ' Clear Errors
End If
Exit Sub

Unstructured: ' Location of error handler
Select Case Err.Number
Case 6
' Display the error number.
MessageBox.Show("Divided by zero")
Case Else
' Catch all other type of errors.
MessageBox.Show(Err.Description)
End Select

'Resume execution to the line following the line that caused the error.

Resume Next
End Sub


Structured Error Handling

Try...Catch...Finally Statements

The following code demonstrates the structure of a Try...Catch...Finally statement.
   Try
'Encapsulates a block of code that may produce a run-time error.
Catch [Optional Filters]
'The code runs if any of the statements in the Try block fails and filter is evaluated as true.
[Additional Catch Blocks]
Finally
'Code executed after Try and Catch statement.
End Try
The code that is expected to generate a run-time error should be placed in the Try block for monitoring by the error handler. If this code produces an error during execution, Visual Basic examines all of the Catch statements implemented within the Try...Catch...Finally block to find a condition that matches the error. If Visual Basic finds a matching condition, the control of execution is transferred to the first line of code within the Catch statement. If Visual Basic does not find a matching condition, the error is propagated to the outer Try...Catch...Finally statement. This statement can be located in the same procedure (nested statements) or in a previous procedure that called the one that produced an error. This process is repeated until a matching statement is found. If a matching statement is not found, an error is produced, and the application is terminated.

The Finally statement is executed last, regardless of whether any errors were found. In other words, if no matching Catch statement is found, the Finally statement executes prior to the propagation to the outer statements.

This hierarchy and propagation are demonstrated with the following code:
   Module StructuredError
Sub Main()
Try
fnStructured()
Catch ex As Exception ' Catches all exceptions.
Debug.WriteLine("Exception Information: " & vbCrLf & ex.ToString)
'Displays the representation of current exception.
Finally
Debug.WriteLine("Main: Finally executed !")
End Try
End Sub

Public Sub fnStructured()
'Nested Error Handling
Try
Try
Dim X As Integer = 9
Dim Y As Integer = 0
Dim Result As Integer
Result = X / Y
Catch e As DataException ' Catches only DataException.
'Displays the representation of current exception.
Debug.WriteLine("Exception Information: " & vbCrLf & e.Message)
Finally
Debug.WriteLine("fnStructured: Inner Finally executed !")
End Try
Catch e As InvalidCastException ' Catches only defined exception.
'Displays the representation of current exception.
Debug.WriteLine("Exception Information: " & vbCrLf & e.ToString)
Finally
Debug.WriteLine("fnStructured: Outer Finally executed !")
End Try
End Sub
End Module
In the preceding example, an error is generated in a fnStructured() procedure. This is a Stack Overflow error, caused by division with a zero (0). This procedure implements two Try...Catch...Finally blocks of statements, but neither one has matching Catch statements, and the error is not caught. Before the control is propagated in the call stack, the code that is encapsulated in the Finally block is executed. The Try...Catch...Finally block that is implemented in the Sub Main has a general condition that catches all exceptions that are thrown in its Try block


More...

Owner Contact


name : yan azmi

address : situjuh padang kuning - payakumbuh - sumatera barat

jl.kampung tanjung 11 - lubeg - padang


e-mail
: yanazmi@gmail.com

phone :
07519780567

More...


Follow This Blog....!!!

More Blogger Update

 

Copyright © 2009 by : ameykurdt

Site Meter yang nyasar sejak Rabu, 27 Mei 09