Announcement

Collapse
No announcement yet.

vbCrLf, vbCr, vbLf --- Difference??

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • vbCrLf, vbCr, vbLf --- Difference??

    I have always used "vbCr" to cause a carriage return and line feed when writing my macros. I've tested "vbCrLf" and "vbLf", and the difference between the 3 of them eludes my understanding. Are they, in fact, identical??

  • #2
    Re: vbCrLf, vbCr, vbLf --- Difference??

    I think the vbCrLf is exactly the same as the two commands vbCr and vbLf. You might only want a carriage return one day or you might want both a carriage return and a line feed the next.

    Simple as that. i think.
    Only Smarties have the answer

    Comment


    • #3
      Re: vbCrLf, vbCr, vbLf --- Difference??

      Hi Cyberdude,

      Welcome to the forum.

      Just to add to Matt's comments - you can see a brief summary here.
      (Personally, I tend to use vbNewline)

      HTH
      Cross-poster? Read this: Cross-posters
      Struggling to use tags (including Code tags)? : Forum tags

      Comment


      • #4
        Re: vbCrLf, vbCr, vbLf --- Difference??

        Thanx for the comments, Guys. The VBA Help shows the same list that you referenced, Matt. I was afraid there might be some sort of subtle difference that would come back to haunt me sometime. Somewhere recently I saw a comment that "vbCr" could somehow change a cell's characteristics to include "Wrap". I'm not sure how that would work, but it's that sort of (undocumented) subtle difference that I was wondering about. It's amazing how terse the Help can be sometimes. Thanx again for the assist.

        Comment


        • #5
          Re: vbCrLf, vbCr, vbLf --- Difference??

          I am sure I will get a back lash for this but here goes!

          vbXXX statements are handed down from VB not VBA at all it is one of those crossed over this – Excel / VBA uses char(xx) to do the same thing, history have developed and programmes jumped from VB to also VBA and so on so the odd VB syntax popped up and funny enough works in VBA – I must say there are wicked syntax that is running in VB that can be used in VBA but Your never find it documented in VBA anywhere odd but true – this are what I call grey cross’s and hard but workable thus why the are vbXXX (vbScript syntax not VBA syntax)

          When You work in VB (Jack never does but …) then everything in that environment is constructed in VBA we kind of steal / borrow / convert / use what is already inside that application VBA and so in VB world these syntax subtle as they are count big time, in Excel nar go for it toss it in Your code and try it and if needs be the old find and replace will solve that and re-test and see if You have as You want – if not try again – see You jig what we have often and VBA is tolerant to this, VB is not quite so.

          Oh well bring on the onslaught of remarks for the errors in what jiuk has said – cant be that far out if at all

          jiuk

          Comment


          • #6
            Re: vbCrLf, vbCr, vbLf --- Difference??

            Thanx for the thoughts, jiuk. You just might be right.
            SAB

            Comment


            • #7
              Re: vbCrLf, vbCr, vbLf --- Difference??

              Here are some examples i wote Click here for link page

              jiuk

              Comment


              • #8
                Re: vbCrLf, vbCr, vbLf --- Difference??

                As Richie says, vbNewLine is far easier to remember!!
                Hope that Helps

                Roy

                New users should read the Forum Rules before posting

                For free Excel tools & articles visit my web site

                If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

                RoyUK's Web Site

                royUK's Database Form

                Where to paste code from the Forum

                About me.

                Comment


                • #9
                  Re: vbCrLf, vbCr, vbLf --- Difference??

                  Two comments:
                  1) I've never seen the "square box" that was referred to, and I've been using vbCr for at least 5 years, and written several hundred macros,
                  2) vbNewLine is considerably longer to type:
                  " ..." & vbCr & vbCr
                  vs
                  " ..." & vbNewLine & vbNewLine
                  to produce a double line feed. In fact I chose vbCr over VbCrLf for the same reason. I suppose as long as I don't see any adverse results, there's no reason to change.
                  Thanx again, Guys!

                  Comment


                  • #10
                    Re: vbCrLf, vbCr, vbLf --- Difference??

                    The "square box" will usually appear when switching between Windows versions and Mac versions.
                    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us will be ignored.

                    Comment


                    • #11
                      Re: vbCrLf, vbCr, vbLf --- Difference??

                      Try the example i gave and do not wrap text in the cell see whay happens

                      jiuk

                      Comment

                      Working...
                      X