Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB2008 equiavlent of VBA String$(254, 0)

908 views
Skip to first unread message

macroapa

unread,
Feb 17, 2009, 10:38:02 AM2/17/09
to
Hi,

I have the following code from VBA:

String$(254, 0)

and want to convert it into code that will work in VB2008.

Can anyone help?

Thanks.

Dick Grier

unread,
Feb 17, 2009, 12:18:22 PM2/17/09
to
I think you have to write your own function for this. It shouldn't take
more than a couple of minutes to write. BTW, I think the syntax is
String$(254, Chr(0)) or String$(254, "0"), depending. Just to prove my
guess, I timed how long it took to write this code:

Private Function FillString(ByVal Count As Integer, ByVal Character As Char)
As String

Dim RetVal As String = ""

For I As Integer = 1 To Count

RetVal += Character

Next

Return RetVal

End Function

Less than 2 minutes.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.


Al Reid

unread,
Feb 17, 2009, 12:53:08 PM2/17/09
to
"macroapa" <macr...@hotmail.co.uk> wrote in message news:70fdcdd2-5c8f-478f...@n21g2000vba.googlegroups.com...

You can use:

Dim s as String = StrDup(254, Chr(0))

It works in VB2005. However, you should direct VB.Net questions to microsoft.public.dotnet.languages.vb.
--
Al Reid


0 new messages