Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem creating StringBuilder object

Status
Not open for further replies.

GMcNamara

Programmer
Jun 24, 2002
235
US
I am creating a VB.NET windows app in VS.NET 2003. The app is very simple in that I am just trying to become familiar with using the StringBuilder object. I have a single button on the form and in the click event for the button I am trying to create a new StringBuilder object.
I have included the Imports System.Text statement at the top of the code. When I enter:
Dim sb As StringBuilder = New StringBuilder("text")
I get a squiggly line under the word StringBuilder (the first one) and the tooltip says 'Type expected'. The strange thing is that I have sample code that I downloaded from a book I am working with and it appears to be setup identically and it works, so the problem does not appear to be a strange configuration issue with my machine.
Is the StringBuilder object limited in where it can be created? Anyone have ideas what the problem is? Thanks in advance.
 
That code should work (just tried it on my machine).

Where are you trying to create the code?

D
 
That is what is so frustrating. It is working in the app that I download but it won't work in my simple version.

I have the code in the click event of the button. I tried to use the same code in the Load event of the form also with the same results. I started again from scratch and I am still getting the same problem.
 
Full qualification works - no more error. What causes this? I thought the point of the Imports statement was to eliminate the need to fully qualify names.
 
The only line other than my import statement is
Dim sb As New StringBuilder("text")

The full qualification is working so for now that is fine. I will look at this again later and post if I find the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top