Microsoft KB Archive/316137

= Error message when you use square brackets as a delimited identified in Visual Basic 2005 or in Visual Basic .NET: &quot;Identifier expected&quot; =

Article ID: 316137

Article Last Modified on 12/6/2006

-

APPLIES TO


 * Microsoft Visual Basic 2005
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



This article was previously published under Q316137



SYMPTOMS
If you use square brackets ([]) as a delimited identifier in Microsoft Visual Basic 2005 or in Microsoft Visual Basic .NET, the wavy blue underline appears under the code in the IDE. If you move the pointer over the code, you receive the following text:

Identifier expected.



RESOLUTION
To resolve this behavior, use parentheses and double quotation marks instead of square brackets.



STATUS
This behavior is by design.

Square brackets are now used to allow keywords to be used as identifiers.



Steps to Reproduce the Behavior
 Open Visual Studio 2005 or Visual Studio .NET. On the File menu, select a new Windows Application project.  Double-click the default form, Form1.vb, to open the code window, and then copy the following code in the Form Load event: Dim dt As New System.Data.DataTable Dim dr As System.Data.DataRow dt.Columns.Add(&quot;Field1&quot;, GetType(String)) dt.Columns.Add(&quot;Mr.Smith&quot;, GetType(String)) dt.Columns.Add(&quot;A space&quot;, GetType(String))

dr = dt.NewRow dr!field1 = &quot;test1&quot; dr![Mr.Smith] = &quot;test2&quot; dr![A space] = &quot;test3&quot;

The wavy blue underline appears under the last two lines of the code in Visual Basic .NET IDE.

  Change the last two lines to the following syntax: dr(&quot;Mr.Smith&quot;) = &quot;test2&quot; dr(&quot;A space&quot;) = &quot;test3&quot; The wavy blue underline disappears. 

Additional query words: brackets delimited identifier

Keywords: kbvs2005swept kbvs2005applies kbprb KB316137

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.