Is it possible to enable syntax highlighting for Microsoft Visual Basic? - vba

I am working on a very old project which needs to be updated. Because the program needs to be backwards compatible, the changes need to be made in this older IDE.
There is no built in syntax highlighting that I see. Is there a plugin or menu that I have missed?

Within VB Editor, go to Options then Editor Format and adjust colours.
There are also some 3rd party softwares out there that will enable you to edit your code with syntax highlighting.
UltraEdit Visual Basic Editor

Related

Visual Studio Code going down to line automatically

I am using Brackets at the moment i want to switch to Visual Stuido Code but some features of Brackets are very usefull.
One of them, i use the editor narrowly, Brackets going under line automatically if it is not fit the line, but Visual Studio Code does not.
And second one also is when i design a html i can see the differences in live preview, is it possible to see it in Visual Stuido Code also?
Visual Studio Code
Brackets
You want to enable the Word Wrap in Visual Studio Code.
Go to View -> Toggle Word Wrap.
Live Preview is actually possible in every editor you use. Today's devs use task automators like Gulp or Grunt, so they are not attached to specific editor like Brackets.
Using Gulp (or Grunt) you can set up a task that will watch your files for changes and then do specific actions, like reload the page, recompile Sass files etc.
You can find more here:
https://www.youtube.com/watch?v=r5fvdIa0ETk

Is it possible to write Excel VBA Code in Visual Studio

Is there a way to write VBA Code in Visual Studio. If not is there any other alternatives?
The best you can do is bend the office Visual Basic Editor (VBE) tool to your liking. If you stay in it's native environment you get the full power of error detection, Intellisense, live code running, etc.
My tips...
In the VBE go to Tools > Options > Editor tab.
Turn off 'Auto Syntax Check'. You still get code highlighted errors but no annoying popups.
Go to the Editor Format tab and change the Font to Consolas (Western), Size 11.
For code indenting install the awesome, free, Code Manager. It adds some sick keyboard shortcuts.
Make the Edit toolbar easily accessible for code commenting/uncommenting.
Use Rubberduck to add unit testing, source control, code inspections and refactoring functionality.
With those simple changes you end up with a half way decent, useful, and keyboard friendly environment to write your visually appealing code. :-D
VBA code for Excel can only be written inside Excel using the VBA IDE. VBA projects are stored as part of the Excel file and cannot be loaded into Visual Studio.
However, you can write VSTO (Visual Studio Tools for Office) managed add-ins for Excel using Visual Studio. The following MSDN page covers both developing with VBA and VSTO.
Excel for developers
You could also use the interop features of VBA to consume a (COM) object written in Visual Studio from your VBA code.
I've been looking for an answer to this question myself.
Best I've found myself is the option of exporting a Module ect from Excel with the code you've already written (or blank) and load that up in the Visual Studio Environment.
It doesn't offer much, but the highlighted text and auto indenting is nice and makes it much easier to read compared to the standard VBA environment.
Then once you're done just import it back into Excel.
There is a VSCode extension to do this.
It allows you to write code in VSCode and export it to Excel.
This extension is very useful when you develop in VBA.
Here's the link to download the XVBA extension
Edit :
As Peter Macej said in comment, this solution only works for Visual Studio Code not for Visual Studio
You can certainly add and edit a VBA file (.vb) in your Visual Studio solution, but the intellisense will be worthless/screwed up.
This extension for VScode would probably provide a much better experience: https://marketplace.visualstudio.com/items?itemName=spences10.VBA
If your goal is have your VBA code exposed to source control so you can track changes, then it's still worth it to include in your Visual Studio solution, but just store that VBA code in a plain text file and then use the Excel interop to load it into the appropriate module within the excel workbook, e.g.:
xlWorkbook.VBProject.VBComponents["ThisWorkbook"].CodeModule.AddFromFile(#"C:\PathToYour\VBAcode.txt");
And there are other methods to delete/replace code lines, etc....
You can try xlWings package for python and use it with VS Code https://youtu.be/xoO-Fx0fTpM

VS 2010 adding spaces at line end in AssemblyInfo.vb

I'm working in VB in Visual Studio 2010, trying to keep the lines in my AssemblyInfo.vb file clear of extra whitespace at the end. I track my projects with git using GitHub's Windows client and the powershell environment it ships with, so when I do a git diff I get red marks wherever there's erroneous whitespace.
Basically what I've found is that if I remove the whitespace in Visual Studio and save the file, it comes back. If I remove it in Notepad++, save, and reopen it in Visual Studio, the whitespace stays gone. After that, as soon as I change anything on a line, Visual Studio adds a space to the end of each line that I've changed which happens to end with > otherwise. If I change the end of the tag to />, it doesn't add the space, but of course that doesn't compile.
I've dug through the Text Editor settings for Basic, XML, and All Languages, but don't see any setting specific to this. Is there one I'm missing, or should I plan on using notepad for version changes? I'll also mention that I have Visual Studio 2012 on my personal machine, and it doesn't seem to do this there.
Is there any reason why you cannot use project properties?
Ah, found it. For future reference, it's part of "Pretty listing (reformatting) of code" in Text Editor > Basic > VB Specific. Thought I had that turned off already.

Disabling Intellisense Auto Line Return [duplicate]

When editing C# code in Visual Studio 2010, the ENTER key makes IntelliSense complete the current suggestion, without adding a new line.
In VB.NET, the default IntelliSense behavior for the ENTER key is to add a new line after completing the current suggestion.
How can I configure IntelliSense to change the VB.NET behavior to the C# one?
I already know that I could press TAB or SPACE, but out of habit I always end up hitting ENTER (and changing line).
UPDATE VISUAL STUDIO 2017:
Now with Visual Studio 2017 you can change it. Tools -> Options -> Text Editor -> Basic -> IntelliSense.
In Enter key behavior select Never add new line on enter
ANSWER FOR VISUAL STUDIO 2015 AND PREVIOUS:
If you want to avoid inserting new line on enter with autocomplete suggestion, just don't press enter. Instead of Enter press Space bar which completes your autofill and just inserts a space.
Or you may use this third party app:
Resharper makes it possible overriding Visual Studio intellisense and using its own intellisense. It is the only way I've found.
It has a 30 days free trial if you want to test it.
Unfortunately the set of trigger keys for intellisense completion is not a configurable item for VB.Net. There is no way in the default Visual Studio environment to change this behavior.
It would be possible to develop a plugin of sorts to accomplish this. However that's a pretty extreme measure.
EDIT
As of Visual Studio 2017, it is now possible to change this. See the answer below

Is there a way to syntax highlight an If - End If statement in VB.Net

I am trying to read through some code and it would be helpful if the editor in VS 2008 would highlight the If statement by using the cursor and double clicking the End If statement (or something like that).
I believe I could do something like this in Java using Eclipse - it was very good at highlighting a code block by clicking next to one of the curly braces.
Anyone know how to do this kind of thing?
I don't think this is possible by default in regular pure Visual Studio installation - statement blocks are not highlighted in VB.NET.
There are many text-highlighting plugins (like Visual Assist X etc.) some of them are free, maybe some of them provide this feature.
I use Expression Studio 3, in the code editor all the bloks have a visible indentation, I wish this could be in VS too...
I think that VS 2010 has implemented it so don't waste time on creating your own plug-in (unless you do it for fun...).