Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

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

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
0
rodmjay
Asked:
rodmjay
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Instead of vbCrLf, you can also use:
 
    Environment.NewLine
0
 
hatem72Commented:

VbNewLine Still Work 2
0
 
rodmjayAuthor Commented:
If you could just translate what those two strings would be that would be great
0
 
SanclerCommented:
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now