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

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.

Related

Break a comment at a single line of code in 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.

Deleting a line from a multiline flxText

How can I delete the first line from a flxText?
I have tried text.textField.replaceText(0, text.textField.getLineLength(0), ""); but it only works once. I have also tried keeping count of the line that's being deleted and it doesn't work either.
edit: I would like to reopen this question to specify that I want to take into account both newlines and word wrap.
Considering the text contains the line breaks why not just split the text on \n, remove the lines you no longer need, and then set the text to the joined lines.
var lines = flText.text.split("\n");
lines.shift(); // removes the first line
flText.text = lines.join("\n");

Why 'New Line' takes two characters?

I made a .txt file (UTF-8) and put the following text in it:
123
456
789
I then tried to find out the position of the character '4' by using the InStr() function. Surprisingly, the result was 6. I tried with the character '3', and the result was 3. So, there must be two characters in between the 3 and the 4.
I then tried InStr(TextBox1.Text, Chr(13)) and the result was 4.
Ok. The "New Line" has a character located in the 4th position. If so, then what is 5th character in there?
The actual character(s) used for new-line are different from one platform to the next. Some systems use character 13 to mean a new-line, some use 10, and some, like Windows, use both.
Technically, character 13 is supposed to mean a carriage return (return the print head of the printer to the left side of the page), that's why it's often referred to as CR. Remember, in the early days of computing, printers were used as terminals rather than video screens. So, the closest equivalent of CR on a video terminal is for the cursor to return to the beginning of the current line, but not advance to the next line.
Character 10 means line-feed (LF), which means to advance (i.e. feed) the paper by one line so that the print head is ready to print on the next line. The closest equivalent to a line-feed on a video terminal is to move the cursor down to the next line, but keep it at the same x-position.
So, with those two-things in mind, if you wanted to begin typing at the beginning of the next line, you would need to do both things. You need to advance to the next line on the page AND return to the beginning of the line, hence CRLF, two characters.
Presumably, some system designers thought it was too wasteful to use two characters for each new-line, when the added nuance was rarely needed for computers with video displays, so they opted to only use either CR or LF. Since the correct encoding to use changes from one platform to another, it's best to use Environment.NewLine in .NET to get whichever is appropriate for the current system.
Consider, for example, when you run this console app on windows:
Public Sub Main()
Console.Write("123" & vbCr)
Console.Write("4" & vbCr)
End Sub
The output is:
423
The carriage-return only caused the cursor to go back to the beginning of the line. It didn't cause it to move down to the next line, so the 4, when it's printed, overwrites the 1.

Visual Basic pulling a character from a certain line number

I am working on a macro that needs to be able to check and make sure that a character on a certain line is what it should be before it finishes the form.
Where or how do i find the information to do this?
I have tried using the command "Left(#of line ,1)" and am not getting it to return anything at this point.
I Assume that you have this text in a string. Comment to my answer if wrong.
You can use a Regex to compare to string with your character like so :
If Regex.IsMatch(MyString, *.{X}Y) Then
'You have to manually replace X for the number of characters before the character you scan for
'You have to manually replace Y for the-said character it is supposed to be
Look at http://www.codeproject.com/Articles/9099/The-Minute-Regex-Tutorial for more info on Regex.
If you want to only take one line in your string :
TheLine = split(MyString,Environnement.Newline)([Line Number])

How to paste text to end of every line? Sublime 2

I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line.
test line one
test line two
test line three
test line four
...
Say you have 100 lines of text in the editor, and you want to paste quotation marks to the beginning and end of each line.
Is there an easy way to do this or a plugin that anyone would know of? This would often save me a lot of time on various projects.
Thanks.
Yeah Regex is cool, but there are other alternative.
Select all the lines you want to prefix or suffix
Goto menu Selection -> Split into Lines (Cmd/Ctrl + Shift + L)
This allows you to edit multiple lines at once. Now you can add *Quotes (") or anything * at start and end of each lines.
Here's the workflow I use all the time, using the keyboard only
Ctrl/Cmd + A Select All
Ctrl/Cmd + Shift + L Split into Lines
' Surround every line with quotes
Note that this doesn't work if there are blank lines in the selection.
Select all the lines on which you want to add prefix or suffix. (But if you want to add prefix or suffix to only specific lines, you can use ctrl+Left mouse button to create multiple cursors.)
Push Ctrl+Shift+L.
Push Home key and add prefix.
Push End key and add suffix.
Note, disable wordwrap, otherwise it will not work properly if your lines are longer than sublime's width.
Let's say you have these lines of code:
test line one
test line two
test line three
test line four
Using Search and Replace Ctrl+H with Regex let's find this: ^ and replace it with ", we'll have this:
"test line one
"test line two
"test line three
"test line four
Now let's search this: $ and replace it with ", now we'll have this:
"test line one"
"test line two"
"test line three"
"test line four"
You can use the Search & Replace feature with this regex ^([\w\d\_\.\s\-]*)$ to find text and the replaced text is "$1".
Use column selection. Column selection is one of the unique features of Sublime2; it is used to give you multiple matched cursors (tutorial here). To get multiple cursors, do one of the following:
Mouse:
Hold down the shift (Windows/Linux) or option key (Mac) while selecting a region with the mouse.
Clicking middle mouse button (or scroll) will select as a column also.
Keyboard:
Select the desired region.
Type control+shift+L (Windows/Linux) or command+shift+L (Mac)
You now have multiple lines selected, so you could type a quotation mark at the beginning and end of each line. It would be better to take advantage of Sublime's capabilities, and just type ". When you do this, Sublime automatically quotes the selected text.
Type esc to exit multiple cursor mode.
Select all lines you want to add a suffix or prefix.(command+ A to select all the lines)
Press command+shift+L. This will put one cursor at the end of every line and all the selected lines would still be selected.
For adding suffix press command+right and for adding prefix command+left. This will deselect all the earlier selected text and there will only be cursors at the end or start of every line.
Add required text