First Hard Return Ignored in Posted Code

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
2,787
Office Version
  1. 365
Platform
  1. Windows
When I put code within the Brackets, the code looks fine until I submit. I look at the post and the first line within the subroutine ends up at the end of the subroutine line. Example Below. I know I can have an extra line between the SUB name and the first DIM statement, but I seem to forget quite often. Does this happen to anyone else. And Why???

Code:
Private Sub txtBatchcode_Change()If Inputfrm1.txtBatchcode <> "" Then
  MsgBox "Please complete the " + Inputfrm1.txtExpDate + " field."
End If
End Sub
 
This has happened to me but not every time.
 
Are you writing in chrome ?
 
if you write in excel, then copy paste a sub, does that format correctly
 
I use Chrome and usually copy and paste my code in, then highlight the code and click on the Code tags.
Usually, it will put in extra blank rows for me (too many line breaks instead of not enough).
 
Thank you Joe. I ran a test in the Test forum. If I copy the Sub from Excel, paste it in, then apply the code tags, every thing works well. I was adding the code tags and then pasting the code.
 
Thank you Joe. I ran a test in the Test forum. If I copy the Sub from Excel, paste it in, then apply the code tags, every thing works well. I was adding the code tags and then pasting the code.
Interesting that the order that things are done in seems to matter. That is good to know, going forward (for when that question arises again).
 
Interesting that the order that things are done in seems to matter. That is good to know, going forward (for when that question arises again).
I'm not sure the order is the problem universally. I use Chrome & usually type the code tags first then paste my code. I don't remember ever having the disappearing return or extra lines. I suppose it could have happened bur at most it is extremely rare for me.

When posting code I usually actually use the VBHTML Maker as referenced in my signature block, but my comments above refer specifically to the times I just Copy/Paste my code.
 
I ran another test on the TEST forum. Two selections of code were pasted, both were pasted after pressing the # to apply the [ CODE ] . On the first one I pushed my first line of code below the CODE. On the second one, I left it alone. No difference

Result: Pasting code then applying the [ CODE ] blocks works without moving one of my DIM lines to the same row as the SUB statement.
 

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top