Using Constants

Directives

8.1 Use For Next to loop a specific number of times.

The most basic type of loop is the For Next loop, which loops a specific number of times. When the maximum number of iterations is reached, execution continues with the statement following the Next statement. When you create a For Next loop, you designate the starting number to use for counting as well as the ending number. You can also specify an increment by using the Step keyword.

The For Next construct has the following syntax:

For  counter start  To  end [Step  step]    [statements]    [Exit For]    [statements] Next [counter] 

The For Next construct has these parameters:

  • counter

    A required numeric variable used as a loop counter. The variable can't be a Boolean or an array element.

  • start

    A required initial value of counter.

  • end

    A required final value of counter. When counter reaches the end number, the statements within the loop are executed one last time and then execution continues with the line following the Next statement. If counter exceeds the end number, execution continues with the line following the Next statement.

  • step

    An optional number that specifies the amount counter is incremented each time through the loop. If you omit step, the counter variable is incremented by 1.

Most of the programming work in a For Next loop is done in the For statement that starts the loop. The majority of For Next loops are fairly simple the loop counter proceeds from one number to another by a step of 1. When you want a step of 1, you should omit the Step component. For instance, the following statement loops from 1 to 10 with a step of 1:

Dim intCounter As Integer For intCounter = 1 To 10     Next intCounter 

To increment the counter by a step other than 1, you must supply the Step component in the For statement. For example, to loop from 1 to 10 with a step of 2, you could use this For statement:

Dim intCounter As Integer For intCounter = 1 To 10 Step 2    Debug.WriteLine(intCounter) Next intCounter 

To create loops that perform as you expect them to, you must fully understand the Step component. If you were asked to count to 10 by 2s, you'd probably count as follows:

2, 4, 6, 8, 10 

However, the code shown above actually prints the following values in the Output window:

1, 3, 5, 7, 9 

When you begin a loop with a For statement, the counter variable is initialized to the start value. In this example, the start value is 1. Once the loop executes, the counter variable is incremented (or decremented, in the case of a negative step value) by the value of step. This continues until the value of the counter variable passes the end value. When the counter variable reaches 9 and the loop completes, the counter variable is incremented to 11. Because 11 exceeds the end value of 10, the loop doesn't repeat again. Some developers don't understand this behavior. For example, what value is printed to the Output window when the following code executes?

Dim intCounter As Integer  ' Loop 10 times. For intCounter = 1 To 10     Next intCounter Debug.WriteLine(intCounter) 

If your first instinct is to say 10, you're mistaken but you're not alone. When the Next statement is reached and intCounter is 9, intCounter is incremented to 10 and the loop executes again. When the Next statement is encountered while intCounter has a value of 10, the loop doesn't terminate immediately. Instead, intCounter is incremented to 11 and execution once again returns to the For statement. When the For statement evaluates intCounter and finds that it exceeds the end value, code execution moves to the statement immediately following the Next statement, which prints the value of intCounter. The value of intCounter at this time is 11.

More Information

In Chapter 4, "Using Constants and Enumerations," I discussed why you should eliminate magic (hard-coded) numbers in favor of constants. Loops are good places to look for opportunities to use constants.


 

Practical Application 8.1.1 shows how a procedure is more readable when you replace hard-coded numbers in a For statement with constants. In addition to magic numbers and constants, you can also use variables or control values for the start and end parameters. For instance, the following code uses the value of a variable for the upper limit:

Dim intCounter    As Integer Dim intUpperLimit As Integer  ' Initialize upper limit. This value can come from anywhere, ' such as from a control on a form or from a text file. intUpperLimit = 100  For intCounter = 1 To intUpperLimit     Next intCounter 

When you use variable data for the start and end values in a For Next loop, the variables must have valid values. For instance, the following procedure is the same as the previous one, with one small but important change: intUpperLimit is set to -5.

Dim intCounter    As Integer Dim intUpperLimit As Integer  ' Initialize upper limit. This value can come from anywhere, ' such as from a control on a form or from a text file. intUpperLimit = -5 For intCounter = 1 To intUpperLimit     Next intCounter 

This loop doesn't execute at all. When the For statement is first encountered, intCounter is initialized to 1 and compared to intUpperLimit. Because it has a value greater than that of intUpperLimit (yet step is a positive value of 1), code execution moves to the statement immediately following the Next statement. In some processes, this might be acceptable behavior; in others, it might not.

Every For statement must have a corresponding Next statement. You technically don't have to include the counter variable in the Next statement, but you should. Omitting the counter variable isn't much of a problem in a simple procedure with only one loop. But as a procedure grows in size and complexity or as nested loops are created, using the counter variable becomes much more important. For example, consider these nested loops:

Dim intCounter       As Integer Dim intSecondCounter As Integer  ' Create the outer loop. For intCounter = 1 To 100    ' Create a nested loop along with a new counter.     For intSecondCounter = 1 To 100       ' Print the value of the second counter.       Debug.WriteLine(intSecondCounter)    Next Next 

This example has a loop within a loop. Because the counter variables are omitted from the Next statements, it's less clear which Next statement is closing which loop. If there were many statements between the For and Next statements, it would be even more difficult to discern the closing of the loops.

You should indent all statements between the For and Next statements at least one tab stop to make the structure of the code apparent. (Chapter 6, "Formatting Code," discusses indentation in detail, but it's also worthwhile describing its importance here.) Indentation helps to display the flow or structure of code. Loops have a definite structure a beginning, a body, and an end. The beginning and end statements appear at the same level in the hierarchy, with the body statements subordinate. The first statement after a For statement must be indented one tab stop. The indentation of the rest of the body statements depends on their relationship to this first statement.

Tip

If you turn on the autoindentation feature in Microsoft Visual Basic .NET, the body of each For Next loop is automatically indented for you.


 

While most For Next loops are designed to loop a designated number of times, sometimes you need to end a For Next loop prematurely. Many developers make the mistake of using GoTo and a label to exit a loop, as shown in Practical Application 8.1.5. The correct method of leaving a For Next loop is to use the Exit For statement:

Dim intCounter As Integer  ' Loop through the possible days of the month. For intCounter = 1 To 31    ' If the counter is equal to the current day of the month,     ' exit the loop.     If intCounter = Date.Today.Day Then Exit For    Debug.WriteLine(intCounter) Next intCounter 

The preceding code isn't particularly functional, but it illustrates a point. If you must exit the loop early, do it with the Exit For statement.

The key point to look for when choosing a For Next loop over another looping structure is whether the loop executes a known number of times. If so, the For Next loop is probably the best choice, as illustrated in the following examples.

Incorrect:
Private Function RawNumber(ByVal strNumber As StringAs String     ' Purpose   :  Strips an alphanumeric string down to just    '              its numeric component to be used for faxing.    ' Accepts   :  strNumber - a string containing a phone number;    '              e.g., (402) 555-1212.    ' Returns   :  The string with all non-numeric elements    '              removed.     Dim strRaw As String    Dim intLocation As Integer     ' Loop through all the characters in the string.     Do While intLocation <= strNumber.Length - 1       ' Determine whether the current character is numeric.        If IsNumeric(strNumber.Substring(intLocation, 1)) Then          strRaw = strRaw & strNumber.Substring(intLocation, 1)       End If       intLocation = intLocation + 1    Loop     Return strRaw End Function 
Correct:
Private Function RawNumber(ByVal strNumber As StringAs String     ' Purpose   :  Strips an alphanumeric string down to just    '              its numeric component to be used for faxing.    ' Accepts   :  strNumber - a string containing a phone number;    '              e.g., (402) 555-1212.    ' Returns   :  The string with all non-numeric elements    '              removed.     Dim strRaw As String    Dim intLocation As Integer     ' Loop through all the characters in the string.     For intLocation = 0 To strNumber.Length - 1       ' Determine whether the current character is numeric.        If IsNumeric(strNumber.Substring(intLocation, 1)) Then          strRaw = strRaw & strNumber.Substring(intLocation, 1)       End If    Next intLocation    Return strRaw End Function 
Practical Applications
8.1.1 Use a constant for step whenever possible.

Because the value of step is always numeric and its meaning varies from process to process, you should use a named constant rather than a literal value.

Incorrect:
' Draw vertical grid lines on the canvas. For intCounter = 1 To m_intCanvasWidth Step 4    ' Draw a vertical line.    objGraphics.DrawLine(System.Drawing.Pens.DarkGreen, intCounter, _                         m_intCanvasTop, intCounter, n_intCanvasBottom) Next intCounter  
Correct:
Const c_Magnification As Integer = 4 ' Draw vertical grid lines on the canvas. For intCounter = 1 To m_intCanvasWidth Step c_Magnification    ' Draw a vertical line.    objGraphics.DrawLine(System.Drawing.Pens.DarkGreen, intCounter, _                         m_intCanvasTop, intCounter, n_intCanvasBottom) Next intCounter  
8.1.2 Avoid referencing the counter variable after a loop ends.

When a For Next loop ends, the final value of the counter variable isn't equal to the value of end it's higher or lower based on the value of step. If you expect a loop to execute its full number of times, don't use the counter variable after the loop ends.

Although the following procedure marked as incorrect appears acceptable, it contains a nasty bug. When this procedure executes, an exception is generated on the statement that attempts to write in the Output window. The exception is "System.IndexOutOfRange", and it occurs because intCounter is actually 11 when the loop terminates. (The last element in the array has an index of 10.)

Incorrect:
Private Sub FillArray()    ' Purpose   :  Fill an array with values, and print the    '              value in the last element.     Dim intCounter As Integer    Dim aintArray(10) As Integer     ' Initialize the random number generator.    Randomize()    ' Populate the array elements with random numbers.     For intCounter = 0 To 10       aintArray(intCounter) = (10 * Rnd()) + 1    Next intCounter    ' Print the value of the last element.    Debug.WriteLine(aintArray(intCounter)) End Sub 
Correct:
Private Sub FillArray()    ' Purpose   :  Fill an array with values, and print the    '              value in the last element.     Const c_ArrayMax = 10    Dim intCounter As Integer    Dim aintArray(c_ArrayMax) As Integer     ' Initialize the random number generator.    Randomize()    ' Populate the array elements with random numbers.     For intCounter = 0 To 10       aintArray(intCounter) = (10 * Rnd()) + 1    Next intCounter    ' Print the value of the last element.    Debug.WriteLine(aintArray(c_ArrayMax)) End Sub 
8.1.3 Include the counter variable in all Next statements.

Code will still execute if you omit the counter variable from the Next statement, but it will be less readable and therefore more difficult to maintain.

Incorrect:
Dim intLabelWidth As Integer Dim lngPauseCounter As Long  ' Fill the status meter from 0% to 100% For intLabelWidth = 1 To 100    lblMeter().Width = intLabelWidth    lblMeter().Refresh() Next 
Correct:
Dim intLabelWidth As Integer Dim lngPauseCounter As Long  ' Fill the status meter from 0% to 100% For intLabelWidth = 1 To 100    lblMeter().Width = intLabelWidth    lblMeter().Refresh() Next intLabelWidth 
8.1.4 Indent body statements in a For Next loop for visual clarity.

Whenever you have a code construct with a beginning and ending statement, you have a situation that calls for indentation.

Incorrect:
Dim intYear As Integer  ' Fill the date selection combo box. For intYear = 1969 To 2020 cboYear.Items.Add(intYear.ToString) Next intYear 
Correct:
Dim intYear As Integer  ' Fill the date selection combo box. For intYear = 1969 To 2020    cboYear.Items.Add(intYear.ToString) Next intYear 
8.1.5 If you must exit a For Next loop early, use an Exit For statement.

Avoid using GoTo and a label to exit a loop.

Incorrect:
   ' Select the "unassigned" category node in the Tree view control.     For intIndex = 1 To tvwCategory.Nodes.Count       ' Check to see whether this is the "unassigned" node.        If tvwCategory.Nodes(intIndex).Text = c_strUnassigned Then          tvwCategory.SelectedNode = tvwCategory.Nodes(intIndex)          ' No need to keep looking; get out of the loop.           GoTo END_OF_LOOP       End If    Next intIndex END_OF_LOOP: 
Correct:
' Select the "unassigned" category node in the Tree view control. For intIndex = 1 To tvwCategory.Nodes.Count    ' Check to see whether this is the "unassigned" node.     If tvwCategory.Nodes(intIndex).Text = c_strUnassigned Then       tvwCategory.SelectedNode = tvwCategory.Nodes(intIndex)       ' No need to keep looking; get out of the loop.        Exit For    End If Next intIndex 

8.2 Use Do Loop to loop an undetermined number of times.

Sometimes you don't know the exact number of times a loop needs to be executed when the loop starts. You could start a For Next loop with an upper limit that you know is larger than the number of iterations needed (if you know that value), check for a condition within the loop, and exit the loop with an Exit For statement when the condition is met. However, this is extremely inefficient, often impractical, and just plain wrong. When you need to create a loop and you don't know how many times it needs to execute, use Do Loop.

The Do Loop construct comes in a number of flavors. In its most basic form, it has the following syntax:

Do    [statements] Loop 

This particular loop is endless no conditional clause determines when to stop looping. You might need an endless loop on rare occasions game programming comes to mind but more often you'll want to exit a loop when certain conditions are met.

The evaluation of a condition to terminate a Do loop can happen at the beginning or the end of the loop. Also, you can specify that a loop continue when a condition is met or until a condition is met. These options allow you a great deal of flexibility when writing loops.

The following is the syntax of a Do loop that uses the While keyword:

Do While  condition    [statements] Loop 

Here's an example of a simple Do loop that uses this syntax:

' Populate a Tree view control with items from the contacts table. Do While Not (m_rstContacts.EOF)    tvwContacts.Nodes.Add(m_rstContacts.Fields("ContactName").Value)    m_rstContacts.MoveNext() Loop 

As long as condition evaluates to True in this case, as long as the recordset's EOF (end-of-file) property isn't True the loop continues to execute. Note that if condition evaluates to False when the loop first starts, the code between the Do and the Loop statements never executes not even once.

The Until keyword keeps a Do loop going until a condition is met. The following code shows the same loop rewritten using the Until keyword:

' Populate a Tree view control with items from the contacts table. Do Until (m_rstContacts.EOF)    tvwContacts.Nodes.Add(m_rstContacts.Fields("ContactName").Value)    m_rstContacts.MoveNext() Loop 

This code example works exactly like the previous one, but it offers a better solution because it eliminates the need to negate the value of rstCodes.EOF. To use the Do While loop, you have to use Not, which requires extra processing and is a little more difficult to read.

You can use the While or Until keyword in the Loop statement (the closing statement of the loop) rather than as part of the Do statement. When you place them in the Loop statement, condition is evaluated at the end of the loop rather than at the start. This ensures that the loop always executes at least once. You must be careful when you create a loop that checks the exit condition at the end of the loop, as shown here:

' Populate a Tree view control with items from the contacts table. Do     tvwContacts.Nodes.Add(m_rstContacts.Fields("ContactName").Value)    m_rstContacts.MoveNext() Loop Until (m_rstContacts.EOF) 

Note that this code suffers from the extreme possibility of failure. It will execute at least once regardless of whether the recordset is at end-of-file. If the recordset is at end-of-file when the loop starts, an attempt to reference the ContactName column causes a run-time error.

As you design a loop, consider whether it needs to execute at least once. If it does, evaluate condition at the end of the loop.

As with the For Next loop, you can exit a Do loop without using GoTo and a label. However, the correct way to exit a Do loop is to use Exit Do. The following procedure creates a loop that would be endless without the Exit Do statement. In each pass through the loop, the program looks in the list box for the string "ContactNumber". If the string is found, it is removed from the list box. When no more occurrences of the string are found, the loop is exited. Note that using Exit Do is often inferior to placing an effective exit condition at the beginning or the end of the loop.

' Remove all entries with the value 'ContactNumber'. Do    If lstAvailableFields.Items.Contains("ContactNumber") Then       lstAvailableFields.Items.Remove("ContactNumber")    Else       Exit Do    End If Loop 

Note that while this code is acceptable, building the condition into the loop is a better approach, as shown here:

' Remove all entries with the value 'ContactNumber'. Do While lstAvailableFields.Items.Contains("ContactNumber")    lstAvailableFields.Items.Remove("ContactNumber") Loop 

The expression that determines when to exit a loop generally uses a variable that's modified somewhere within the Do loop. Obviously, if the expression never changes, the loop is never exited.

Practical Applications
8.2.1 Evaluate the exit condition of a Do Loop at the start of the loop unless you have a reason to do otherwise.

Often you can choose whether to place the exit condition at the beginning or at the end of a loop. However, loops whose exit conditions are evaluated at the beginning are a bit easier to understand, and they won't be executed not even once, if the condition is False.

Incorrect:
' Populate a Tree view control with items from the contacts table. If Not (m_rstContacts.EOF) Then    Do       tvwContacts.Nodes.Add(m_rstContacts.Fields("ContactName").Value)       m_rstContacts.MoveNext()    Loop Until m_rstContacts.EOF End If 
Correct:
' Populate a Tree view control with items from the contacts table. Do Until (m_rstContacts.EOF)    tvwContacts.Nodes.Add(m_rstContacts.Fields("ContactName").Value)    m_rstContacts.MoveNext() Loop 
8.2.2 When choosing between While and Until, use the one that allows the simplest exit condition.

You can use either While or Until in most loops. However, depending on the situation, one of them (and not the other) will require that you use the Not operator to evaluate the opposite of an expression. You should use the value of a simple expression (rather than its opposite) whenever possible.

Incorrect:
Private Sub RequeryContacts()    Dim strSQL As String    Dim rstContacts As New ADODB.Recordset()    ' Retrieve the contacts, ordered by name.    strSQL = "SELECT * FROM Contacts ORDER BY [ContactName];"    ' Create the recordset of contacts.    rstContacts.Open(strSQL, m_cnADOConnection, _                     ADODB.CursorTypeEnum.adOpenDynamic, _                     ADODB.LockTypeEnum.adLockOptimistic)    ' Add the contacts to the combo box.    cboContacts.Items.Clear()    Do While Not(rstContacts.EOF)       cboContacts.Items.Add(rstContacts.Fields("ContactName").Value)       rstContacts.MoveNext()    Loop    rstContacts.Close() End Sub 
Correct:
Private Sub RequeryContacts()    Dim strSQL As String    Dim rstContacts As New ADODB.Recordset()    ' Retrieve the contacts, ordered by name.    strSQL = "SELECT * FROM Contacts ORDER BY [ContactName];"    ' Create the recordset of contacts.    rstContacts.Open(strSQL, m_cnADOConnection, _                     ADODB.CursorTypeEnum.adOpenDynamic, _                     ADODB.LockTypeEnum.adLockOptimistic)     ' Add the contacts to the combo box.    cboContacts.Items.Clear()    Do Until rstContacts.EOF       cboContacts.Items.Add(rstContacts.Fields("ContactName").Value)       rstContacts.MoveNext()    Loop    rstContacts.Close() End Sub 
8.2.3 Use a Do loop or a For Next loop instead of GoTo and a label whenever possible.

In many situations, it's tempting to create a loop by using GoTo and a label. But this technique creates code that is difficult to understand and often less efficient.

Incorrect:
   Private Function StripDoubleQuotes(ByVal strString As StringAs String        ' Purpose   :  Locate all double quotes within a string and change       '              them to single quotes.       ' Accepts   :  strString - the string in which to search for        '              double quotes.       ' Returns   :  The string passed here as strString, with double       '              quotes replaced by single quotes.        Dim intLocation As Integer       Const c_SingleQuote = "'" StartCheck:       ' Look for a double quote.       intLocation = InStr(strString, ControlChars.Quote)       ' If a double quote is found, replace it with a single quote.        If intLocation > 0 Then           ' A double quote has been found. Replace it with          ' a single quote.          Mid$(strString, intLocation, 1) = c_SingleQuote          ' Look for another double quote.           GoTo StartCheck       Else           ' No more double quotes were found. Return the new string.          StripDoubleQuotes = strString       End If    End Function 
Correct:
Private Function StripDoubleQuotes(ByVal strString As StringAs String     ' Purpose   :  Locate all double quotes within a string and change    '              them to single quotes.    ' Accepts   :  strString - the string in which to search for     '              double quotes.    ' Returns   :  The string passed here as strString, with double    '              quotes replaced by single quotes.     Dim intLocation As Integer    Const c_SingleQuote = "'"    Do        ' Look for a double quote.       intLocation = InStr(strString, ControlChars.Quote)       ' If a double quote is found, replace it with a single quote.        If intLocation > 0 Then           ' A double quote has been found. Replace it with          ' a single quote.          Mid$(strString, intLocation, 1) = c_SingleQuote       End If    Loop While intLocation > 0    ' No more double quotes were found. Return the new string.    StripDoubleQuotes = strString End Function 

8.3 Use Do Loop in place of While EndWhile.

The While EndWhile loop has been around for a long time up until Visual Basic .NET, it was called While Wend and its retirement is long overdue. The Do Loop structure is more flexible and more widely accepted, so you should use it instead. The While EndWhile loop looks like this:

While  condition    [statements] EndWhile 

The While EndWhile loop behaves exactly like the following Do loop:

Do While  condition    [statements] Loop 

There isn't much more to say about the While EndWhile loop. The exit condition is evaluated when the loop is started, and if the condition evaluates to True the code within the While EndWhile loop executes. When the EndWhile statement is reached, execution jumps back to the While statement and the exit condition is reevaluated.

8.4 Use For Each Next to loop through all members of a collection.

A For Each Next loop is a powerful loop that programmers often overlook. It loops through all the members of a collection of objects. For Each Next is designed and optimized to loop through collections of objects. You create an element variable, whose data type must be Object or some specific object type, and then initiate the loop. During each pass through the loop, your element variable is set to reference a different element in the collection. Manipulating the element variable directly manipulates the element in the collection. Using a For Each Next loop is often faster than using a For Next loop that utilizes the indexes of the items in a collection.

The following is the syntax for a For Each Next loop:

For Each  element  In  group    [statements]    [Exit For]    [statements] Next [element] 

The element variable, which you define, must have an Object data type (generic or specific). You should use the specific object type that is most suitable for all objects in the collection (group). For instance, when you loop through the Controls collection on a form, you can use Object or Control as the data type. However, you can't necessarily use the TextBox, ListBox, or ComboBox data types unless you are certain that only controls of the specified type are on the form. Therefore, the logical choice is the Control data type.

Incorrect:
   Public Function IsFormDirty(ByRef frm As FormAs Boolean        ' Purpose   :  Determine whether any of the data on the form       '              has changed.       ' Accepts   :  frm - the name of the form to test.       ' Returns   :  True if even one control's Modified property       '              is True; otherwise False.        Dim intIndex As Integer       Dim objControl As Object        ' Loop through all controls on the form.        For intIndex = 0 To frm.Controls.Count - 1          objControl = frm.Controls(intIndex)          ' Trap the exception that occurs if you attempt to access          ' the Modified property on a control that doesn't support          ' this member.           Try              ' If one control is modified, the form is dirty.              If objControl.Modified Then                 Return True                GoTo PROC_EXIT             End If          Catch As MissingMemberException             ' This control doesn't have a Modified property.           End Try       Next intIndex PROC_EXIT:    End Function 
Correct:
   Public Function IsFormDirty(ByRef frm As FormAs Boolean        ' Purpose   :  Determine whether any of the data on the form       '              has changed.       ' Accepts   :  frm - the name of the form to test.       ' Returns   :  True if even one control's Modified property       '              is True; otherwise False.        Dim intIndex As Integer       Dim objControl As Object        ' Loop through all controls on the form.        For Each objControl In frm.Controls          ' Trap the exception that occurs if you attempt to access          ' the Modified property on a control that doesn't support          ' this member.           Try              ' If one control is modified, the form is dirty.              If objControl.Modified Then                 Return True                GoTo PROC_EXIT             End If          Catch As MissingMemberException             ' This control doesn't have a Modified property.           End Try       Next objControl PROC_EXIT:    End Function 
Practical Application
8.4.1 Use the most specific data type possible in a For Each Next loop.

The element variable in a For Each Next loop must be an Object variable (generic or specific). Objects have many drawbacks, as discussed in Chapter 5, "Variables." If you use a generic Object variable when a specific Object type would work, you prevent Visual Basic from determining errors at compile time (such as referencing properties that don't exist for that type).

Incorrect:
Dim objControl As Object  ' Locate all listboxes on the form. For Each objControl In Me.Controls    ' Is this control a listbox?     If TypeName(objControl) = "ListBox" Then        ' Tell the user the name of the listbox.       MessageBox.Show(objControl.Name & " is a listbox.", _                       "Listbox Found", MessageBoxButtons.OK, _                       MessageBoxIcon.Information)    End If Next objControl 
Correct:
Dim ctl As Control  ' Locate all listboxes on the form. For Each ctl In Me.Controls    ' Is this control a listbox?     If TypeName(ctl) = "ListBox" Then        ' Tell the user the name of the listbox.       MessageBox.Show(ctl.Name & " is a listbox.", _                       "Listbox Found", MessageBoxButtons.OK, _                       MessageBoxIcon.Information)    End If Next ctl


Practical Standards for Microsoft Visual Basic. NET
Practical Standards for Microsoft Visual Basic .NET (Pro-Developer)
ISBN: 0735613567
EAN: 2147483647
Year: 2005
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net