We help IT Professionals succeed at work.

Help translating into vb.net -- 2 lines of code -- 500pts

rodmjay
rodmjay asked
on
Medium Priority
219 Views
Last Modified: 2010-04-23
string return_val = new string((char)10,1);//converts ascii characters.
          string hardReturn = new string((char)13,1); //converts ascii characters.

I came across this code and would like an equivalent for vb.net and something that is valid!  Thanks
Comment
Watch Question

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
The code is making string "constants" for CarriageReturn(Cr) and LineFeed(Lf).

You can just use the built-in VB constants:

    vbCr
    vbLf
   
or the two together:

    vbCrLf
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
Instead of vbCrLf, you can also use:
 
    Environment.NewLine

Commented:

VbNewLine Still Work 2

Author

Commented:
If you could just translate what those two strings would be that would be great
Commented:
These are the most direct equivalents

        Dim return_val As String = Chr(10) 'converts ascii characters.
        Dim hardreturn As String = Chr(13) 'converts ascii characters

And this tests them

        MsgBox("a" & return_val & hardreturn & "b")

Roger

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.