I used to be a C# developer so this commenting style was very easy in C#. This is driving me crazy but how do you do this in VB.NET without getting a syntax error?:
Private ReadOnly Property AcceptableDataFormat(ByVal e As System.Windows.Forms.DragEventArgs) As Boolean
Get
Return e.Data.GetDataPresent(DataFormats.FileDrop) _ 'this is a file that a user might manipulate
OrElse e.Data.GetDataPresent("FileGroupDescriptor") 'this is a typical Outlook attachment
End Get
End Property
You can use Ctrl+K, Ctrl+C and Ctrl+K, Ctrl+U to comment or uncomment selected lines of text.
In Visual Studio . NET you can do Ctrl + K then C to comment, Crtl + K then U to uncomment a block.
Press Ctrl + / To comment more than one line: Select all the lines that you would like to be commented.
Unfortunately you can't. VB.Net doesn't allow comments to appear in the middle of statements which span multiple lines (including both explicit and implicit line continuations). The comments must go above the statement or on it's final line.
The exception to this rule is statement lambdas. It is fine for comments to appear within a statement lambda even though it's technically one statement.
Remove that comment from the line continuation and it should be fine. Comments cannot be used with the line continuation. The line continuation has to be the last character on the line so your comment cannot appear after it.
Here is a similar question: Why must VB.Net line continuation character be the last one on line
So like this:
Private ReadOnly Property AcceptableDataFormat(ByVal e As System.Windows.Forms.DragEventArgs) As Boolean
Get
'Return a file that a user has dragged from the file system
'or a typical Outlook attachment
Return e.Data.GetDataPresent(DataFormats.FileDrop) OrElse
e.Data.GetDataPresent("FileGroupDescriptor")
End Get
End Property
This is a limitation that has been bothering VB developers for a long time.
Apparently this is now possible in Visual Studio 2017
Public Function foobarbaz(ByVal foo As Integer, '' qux
ByVal bar As String, '' quux
ByVal baz As DateTime) '' garply
Return foo.ToString & '' Concatenate foo
bar & '' with bar
baz.ToString '' and baz
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With