By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,681 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,681 IT Pros & Developers. It's quick & easy.

Is String() Function Gone?

P: n/a
TC
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC
Nov 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
TC,

Take a look as string.PadLeft and string.PadRight

These two functions replace the old String() functions

Kirk Graves

"TC" <q@w.e> wrote in message
news:uC******************@news1.central.cox.net...
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC

Nov 20 '05 #2

P: n/a
Look For StringBuilder i think its called.
"TC" <q@w.e> wrote in message news:uC******************@news1.central.cox.net...
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC

Nov 20 '05 #3

P: n/a
Hi,

Yes the string function is gone. You can however create a new
string with repeating characters.

Dim strC As String

strC= new String("C",10) ' New string CCCCCCCCCC

Me.Text = strC

Ken

----------------

"TC" <q@w.e> wrote in message
news:uC******************@news1.central.cox.net...
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC

Nov 20 '05 #4

P: n/a
"TC" <q@w.e> schrieb
Visual Basic used to have a function called String(), which would
create a repeating character string. Is that gone in VB .NET?


s = new string("x"c, 20)
--
Armin

Nov 20 '05 #5

P: n/a
TC,
I would recommend Ken's example

Dim strC As String

strC= new String("C"c,10) ' New string CCCCCCCCCC

Me.Text = strC

Note if you are using Option Strict On (you are using Option Strict On
correct!), you will need to specify a Char literal as opposed to a String
Literal. A Char literal looks like a String literal only it has a lower case
c on the end.

"A"c is a char literal
"A" is a string literal.

There is also the StrDup function found in the Microsoft.VisualBasic.Strings
module that you can use to create the string.

strC = StrDup(10, "C"c)
strC = StrDup(10, "C")

Dim obj As Object = "C"
obj = StrDup(10, obj)

Which is overloaded for Char, String and Object, so its more forgiving with
Option Strict On. Note the Object overload returns an Object, however the
parameter still needs to contain a String or Char.

Hope this helps
Jay
"TC" <q@w.e> wrote in message
news:uC******************@news1.central.cox.net...
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC

Nov 20 '05 #6

P: n/a
"TC" <q@w.e> scripsit:
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?


The function has been renamed to 'StrDup'.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
TC
Thank you all for the replies. I am now much more knowledgeable.

-TC
"TC" <q@w.e> wrote in message
news:uC******************@news1.central.cox.net...
Visual Basic used to have a function called String(), which would create a
repeating character string. Is that gone in VB .NET?

-TC

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.