Visual Studio Keeps deleting the VB line connectors ( _ ) - vb.net

I have some visual basic code where i have a for loop and for company syntax reason, we need to include a _ at the en of the from in line. However, whenever I unfocus from the code, the " _ " gets deleted
I tried messing around in the option under Tools > Options > Text Editor > Basic > advance and unchecking everything but that did not help.
this is the code i want to produce:
Dim burger = (From p In db.PreviousDeclarations _
Where p.burgerID = CompanyID.Value And Object.Equals(p.Year, Year)
This is the code visual studio keep "Correcting" for me:
Dim burger = (From p In db.PreviousDeclarations
Where p.burgerID = CompanyID.Value And Object.Equals(p.Year, Year)

Uncheck Pretty listing (reformatting) of code, located in Options->Text Editor->Basic-> Advanced->Editor Help

Recent versions of Visual Studio will delete the line continuation characters when they're not necessary, typically when the first line alone would not compile on its own but the line below makes it syntactically valid. I know from experience that it's annoying when switching to a new VS that does this, as a small change can easily look like a huge refactoring when doing a diff.
I don't believe there's any way to disable the functionality. If you need them for a company style guideline I suggest you update the guidelines

Related

Format specifiers for VB.NET in Visual Studio in 2013

I've been trying to find a way to render \r\n as actual newlines in the immediate and command window in my VB.NET 4.5.1 application. I came across this question which teaches about the nq specifier, but it appears to apply only to C#. In VB.NET, nq doesn't even appear to work because I get Expression expected printed back out at me.
Is there a different way to make newlines actually show as separate lines in the immediate or command window in VB.NET?
An easier way in visual studio 2015 is to do this in the debug window:
?string,nq
You can also do the debug version in earlier versions of VS
?System.Diagnostics.Debug.Print(string,nq)
I've discovered that the solution is to use System.Diagnostics.Debug.Print(). To reproduce the original issue, entering this into the Immediate window...
? "a" & vbCrLf & "a"
...just returns this:
"a a"
However, using this...
System.Diagnostics.Debug.Print("a" & vbCrLf & "a")
...actually shows the newline:
a
a

Visual Studio 2010 Compare Wildcard

This is new territory for me, VB and visual studio 2010.. I just need to make one change to a piece of code to improve functionality.
If UCase(dvPlaceDisplayList.Item(i)("PlaceName")) >= UCase(ToolStripTxtFind.Text) Then
The issue I am having is that several place names are prefixed with 'The' ..
I need to change the code to Contains or similar using wildcards
As VB is new to me and googling has not provided any answers...here I am
Thanks
The solution is to use:
If UCase(dvPlaceDisplayList.Item(i)("PlaceName")) LIKE "*" & UCase(ToolStripTxtFind.Text) & "*" Then

VB.NET Debug.Print not working, breakpoint disappears

I have a VB.NET application that I run in debug mode.
I have 3 lines
Dim sValue$
sValue = "test"
Debug.Print sValue
When I am not running, I set a breakpoint on the lines sValue = "test", and on the line Debug.Print sValue.
Now when I start debugging, the breakpoint on the line Debug.Print sValue disappears, and the Debug.Print is not performed.
However, the breakpoint on the line sValue = "test" stays there.
Does anybody know what might go wrong here?
Switching from x86 to AnyCPU helped.
Strange.
Community,
Here is another solution for those who are using Visual Studio 2012 (Express) for Desktop. Basically, you will need to import the system diagnostics and include a specific line of code. See below:
Imports System.Diagnostics
'Write Your Code Here
Trace.Listeners.Add(New TextWriterTraceListener(Console.Out))
Debug.Print(Today) 'This will print the date in "Short" form | Carriage Return
Debug.Write(Today) 'This will print the date in "Long" form
Trace.Write(Today) 'This will print the date in "Long" form
That's it. That very first line of code is necessary so that Visual Studio will recognize the Debug & Trace classes. The 2nd line of code is needed so that the window will actually display what you need. The final three lines of code do the exact same thing, essentially.
One more thing, make sure that you are in the Output Window's "Debug" page in order to see the printout!
One last thing, if you are a rookie [like me] please make sure that you hit F5 instead of CTRL+F5 if you want Visual Studio to display "Debug.Print" in your output window.
PS. There was a way to get the output to appear in the Immediate Window; but I changed my settings and now it won't appear. So, if you'd like it there you can tinker around with the options and you'll eventually get it.

Visual Basic 2010 crashes when clicking in specific subroutine

When clicking in a specific subroutine in Visual Basic 2010, the application crashes giving only the error message "Microsoft Visual Basic 2010 [Express] has encountered a problem and needs to close."
Nothing appears in the log and safe mode doesn't help.
When I had this problem, I found it was due to a line continuation over 400 lines.
For example:
Dim someString As String
someString = "some text and then a line continuation " & _
"and then some more text for 400 lines " & _
... & _
"and then finish the string"
To fix it, I just had to make my code a little sloppier by combining multiple "lines" on one line.
Hope this helps someone else!
It sounds like you are clicking on a module or a .vb file in the solution space. Try right clicking, then "edit code" if at all possible. If there is an Interop object, perhaps a control (.OCX) that not's registered ion Windows, then VS will crash -- promise!

ms access visual basic 2010 report does not order by

this one is the screenshot on the visual basic report. as you can see it starts at august then december then february but it i already group by it on the access which is this.
this is a query in the access im not sure if i did the right thing but i is already ordered by the earliest .
here is the sql code from the ms access
SELECT MonthName(Month([Date_sold])) & ' ' & Year([Date_sold]) AS Month_Sold, Sum(tblSell.Total_Price) AS Total_Earnings, Sum(tblSell.Quantity_Bought) AS Total_Medicine_Sold, tblSell.Generic_name, tblSell.Brand_Name
FROM tblSell
GROUP BY MonthName(Month([Date_sold])) & ' ' & Year([Date_sold]), tblSell.Generic_name, tblSell.Brand_Name, Year([Date_sold]), Month([Date_sold])
ORDER BY Year([Date_sold]), Month([Date_sold]);
in short is it doesnt order by on my report on the visual basic it should show february first like the one on ms access but it shows august which is different.
Order by, I believe, gets over written by the reports Order By property in the Data tab, on the property sheet. Either set it there or make sure it is empty. Then set the reports properties like this:
Me.OrderBy = "[SomeField], [AnotherField]"
Me.OrderByOn = True
EDIT:
All Microsoft products allow developers access to a development environment using a language called VBA (Visual Basic for Applications). You can use this language to write programs and macros to enhance products. Take a look here, although it's a bit old it may still be relevant: http://visualbasic.about.com/od/learnvba/l/aa030803b.htm
For you, you will need to add the code I suggested to the OnLoad event of the report. To do this:
Open Access.
Open your report in Design View.
On the left hand side, you should see a tab called Property Sheet
Select the Event Tab
in the OnLoad event, click the "..." (ellipsis) button
This will bring up the VBA code.
Add This:
Private Sub Report_Load()
Me.OrderBy = "[SomeField], [AnotherField]"
Me.OrderByOn = True
End Sub
Try that and see if it works.
The reason why is it not sorting (I am having this same problem at work doing some shipment order reports) is because the code is not reading the date. It will list them aplhabetically because it is a text field and not a short date. I just went to the parameters and was able to fix it there.