Creating a long string

  • Thread starter Thread starter VB Learner
  • Start date Start date
V

VB Learner

This should be so easy it's embarassing, but I've looked & looked on the
inet...
What's the equivalent in VB .NET of the old Basic String$() function?
To create string of 1000 zeros, you'd do

a$=string$(1000,0)

which you don't seem to be able to do in VB .NET. I thought

Dim s As String = Microsoft.VisualBasic.string(1000,0)

but it doesn't like it. Surely everyone must know but me!

(By the way, has anyone the time to look at my other thread "Deleting
from a table via a dataset positioning problem"? I'm still stuck on
that, too.)

Thanks to any assistor,
 
VB Learner said:
This should be so easy it's embarassing, but I've looked & looked on the
inet...
What's the equivalent in VB .NET of the old Basic String$() function?
To create string of 1000 zeros, you'd do

a$=string$(1000,0)

which you don't seem to be able to do in VB .NET. I thought

Dim s As String = Microsoft.VisualBasic.string(1000,0)

but it doesn't like it. Surely everyone must know but me!

There's a string constructor which takes a char and an int. Do you
really want a thousand '0' chars, or a thousand null chars (i.e.
Unicode 0)?
 
Well, thanks. That looks like it's going to work. I wonder why the
weird backwards syntax? Oh well :-)
 
Jim Hughes said:
Dim s As New String("0"c, 1000)

the "c casts the 0 to a Character

Alternatively you can use 'StrDup' in VB.NET.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top