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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stringbuilder object as an array?

Status
Not open for further replies.

olichap

Programmer
Mar 20, 2001
389
US
I'm wondering if you can create an instance of the stringbuilder that is also an array. I'm able to dim the variable:

Dim sbldClaim(6) As System.Text.StringBuilder

When I try to append to say sbldClaim(0) I get the following:

Referenced object has a value of 'Nothing'.

It wants to see that NEW keyword but this can't be done with an array. Any ideas on whether it's possible to have an array of Stringbuilder objects?

O.
 
Have you tried creating each object within the array.

Set sbldClaim(0) = New System.Text.StringBuilder
Set sbldClaim(1) = New System.Text.StringBuilder
... etc....
 
Excellent, that was what I was missing.

Thanks much.

O.
 
May I ask why you need to create an array of string builders? It just seems very odd given what a string builder does. I mean once you used it you can just put the string in a varialbe clear the builder and start with a new string.

I must be missing something. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
I'm looping through some datarows and have to build 6-10 strings off of different fields within the rows. My thought was that declaring a variable as a StringBuilder array would remove the need to specifically declare the instances (thinking setting the array ubound and builder type would handle this). Since I still had to explicitly set each instance I went ahead and created task specific stringbuilder objects.

 
OIC That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top