Link to home
Start Free TrialLog in
Avatar of akohan
akohan

asked on

How to replicate a character


Hello group,

Unfortunately I'm not a VB.net developer but I am reviewing somebody's code where has something like:

WriteAllText("file_name", " ********************************  ", True)

Is there a better way to replicate the * character like replicate or duplicate("*") as argument in the function.

Thanks,
ak

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Alternatively
"".PadRight(10, "*"c)
 
  --OR--
 
"".PadLeft(10, "*"c)

Open in new window

Avatar of Todd Mummert
Todd Mummert

...and another one:

        Dim stars As New String("*", 32)
        MessageBox.Show(stars)
Avatar of akohan

ASKER



May I ask what is the small "c" character at the end of "*" ?

like  "*"c

Thanks.
That converts the String "*" to a Char.

It's not actually necessary for this function as it accepts "any valid Char, String, or Object expression."

It's really on necessary when "Option Strict" is on....since otherwise the implicit conversion is done for you.  You see it more often in C# where the default typecasting is more strict and it's required.
Avatar of akohan

ASKER



Thank you!
Avatar of akohan

ASKER



Thanks to all.