Break a comment at a single line of code in vb.NET - vb.net

Here's a basic one:
Is it possible to break a comment to allow you to continue to write the code at the very same line in vb.NET?
I'm asking because there's a section in my code that I would like to comment the code before the code itself (line by line):
'Comment here <code>
instead of
<code> 'Comment here
I know we can use the tag Rem to initialize a comment instead of ', but I don't know if it's possible to break the Rem (or the ') to continue to write the code.
Please, I know that some of you will point out the badness of this kind of procedure. But I would like to know how to do it anyway...
Thanks

No, you cannot have code after a comment on the same line.
The documentation states:
Comments can follow a statement on the same line, or occupy an entire line.
To have a comment precede code, place the comment on the preceding line.

Related

Word VBA move selection to next and previous review comments in comments pane

I am trying to write VBA and C# code to move the cursor among review comments in Word. I want to do this to provide voice accessibility commands to work with review comments. Some of the behaviors are anomalous and I wonder if I have the right code.
I am working with a normal word document with several paragraphs in it and four review comments visible in the comment review pane. The comments are labeled 1, 2, 3, 4. If my cursor is in the word document, the following snippets will successfully move the insertion point to the beginning of the commented text fields in the main Word document body, as expected.
sel.GoTo(Word.WdGoToItem.wdGoToComment, Word.WdGoToDirection.wdGoToNext);
sel.GoTo(Word.WdGoToItem.wdGoToComment, Word.WdGoToDirection.wdGoToPrevious);
However, if the insertion point is actually within the comment itself, only the “wdGotoNext” code moves the insertion point to the inside of the next review comment. The “wdGoToPrevious” code does not move the insertion point out of the current comment body.
In addition, if I use the following snippet to delete the review comment containing the selection in the comment body, Word moves the selection into the comment body of the following review comment. But I can’t find a syntax to delete a comment and move the selection into the previous comment body.
sel.Comments[1].Delete();
Is there a different API or code syntax that I should be using to move the cursor into and out of the comment bodies themselves? I would like to have code snippets to move the cursor up and down within the Word document mainstory as well as move the cursor up and down inside the comment bodies in the comment pane. Thank you.

Carriage Return in VBscript?

I am writing a script in VBscript and I need to include line breaks or carriage returns. I was using the following code:
objSelection.TypeParagraph()
But this creates to big of a space between lines. The best way I can think to explain it is, when you are in Microsoft word, and you type a line, if you were to press Shift + Enter, you would get two separate lines close together, whereas pressing just Enter will do a full Carriage return (which I don't want). I will demonstrate here.
How can I achieve the same result as 'Shift + Enter' but through VBscript?
Thank you very much.
Assuming you're asking about Word VBA, you can do it like this:
objSelection.TypeText(Chr(11))
Generally, if you can't find out how to do something in VBA that you can do in the application, just record a macro while you perform the required steps and then look and see what VBA has been generated.

How to disable inserting empty line on paste?

Each time I paste a line of code in IntelliJ IDEA it inserts an empty line below the inserted one, how to disable this? Thank you.
That empty line isn't being added by IDEA, it's already included in the selection. Basically you can avoid this by putting the end point of your selection at the last character and not below the block you're selecting.
Figure: http://i.imgur.com/8Digdkz.png

how to break up lines of codes AND comments in VB.NET 2010?

everytime i try the space then underscore + enter it doesnt work and it lights up red
edit - like for example this is a comment:
'you must add such and such to this variable and then you must declare it'
say i have that for a comment and i want to break the comment after variable. when i do this
'you must add such and such to this variable _
and then you must declare it'
it gives me an error
The underscore at the end of the line trick doesn't work for comments. The underscores are treated as part of the comment.
To create a bunch of single line comments at once, select the lines you want to comment out and press CTRL+K then CTRL+C
A line continuation consists of at least one white-space character that immediately precedes a single underscore character as the last character (other than white space) in a text line.
Ref.
Doesn't apply to comments though; if you want multiple comment lines simply start a new comment for each subsequent line.

Easy way to write a string with control characters to an nvarchar field in a DB?

EDIT: Accepted answer points out what my issue was. I added another answer which shows an even easier way.
I have a multiline textbox from which I create a single string:
Dim wholeThing As String
Dim line as String
For Each line In txtMultiline.Lines
wholeThing = wholeThing & line & Environment.Newline
Next
What I'd like to do is write this to a DB as-is by adding wholeThing as a parameter using to SqlCommand.Parameters.AddWithValue, but all of my painstakingly-inserted newlines go away (or appear to).
I saw this and was hoping I didn't need to concern myself with CHAR(nnn) SQL stuff.
Any suggestions? Thanks!
What do you mean when you say "appears to"? A newline character can be easily stored in an nvarchar field. What tools are you using to verify the results of your actions?
It's even easier than this. As per the discussion in the accepted answer, I wasn't seeing all of the lines in my view. Putting up a messagebox showed everything.
What's more, I don't need to take things line by line:
wholeThing = txtMultiline.Text
works, too, and it keeps all of the line breaks.