They say you learn something new every day.

Stringing it out (19/02/2012)

So, everyone knows string concatenation is bad. And by everyone, I mean everyone who understands vbscript or ASP and then me.

However, even though I’ve always known it’s bad, I haven’t really seen a way around it, without writing an array and constantly re-diming it. Which is… well, a mess really.

However, I came across the ADO textstream function the other day that allows you to do something like this:

Set Stream = CreateObject(“ADODB.Stream”)
Stream.Type = 2
Stream.Open

’ This is where you put your loop

Stream.WriteText “test”
Stream.WriteText “test2”

’ End your loop here

Stream.Position = 0

Value = Stream.ReadText()

It’s surprisingly concise. Now, maybe, in some circumstances, there is a quicker way than this. But that requires a complex extra function, whereas this is so neat.

Time to go back and rewrite some things, I think.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: