Visual Studio Code for Visual Basic
Legend
Contributors
This is a fork of the repository provided by spences10!
All credits goes to this amazing guy.
Changelog
- Fixed error with some snippet.
- Added highlight for methods.
Syntax Highlighting
This package provides syntax highlighting and snippets for visual basic.
All are based on an import of the VBScript.tmLanguage
file from the Sublime Text VBScript repository.
Snippets
Basic code
- Variables declaration (ex. dim var_name as boolean)
- Variables declaration with inline instantiation
- Operators (if, else, for ecc)
- Subroutine/Function declaration with or without error handling
Usage
Start typing what you want to insert and suggestion should raise:
Variables declaration
Type the variable type:
dim var_name as boolean ' by typing bool
dim var_name as integer ' by typing int
dim var_name as string ' by typing string
dim var_name as type ' by typing type
For private or public declaration type p or pu before the type:
private var_name as boolean ' by typing pbool
public var_name as boolean ' by typing pubool
private var_name as integer ' by typing pint
public var_name as integer ' by typing puint
private var_name as type ' by typing ptype
public var_name as type ' by typing putype
For declaration with inline assignment type a before the type:
dim var_name as boolean: var_name = value ' by typing abool
dim var_name as integer: var_name = value ' by typing aint
dim var_name as type: var_name = value ' by typing atype
Subroutine and functions
Type sub or func for a standard private method:
' by typing sub
private sub sub_name()
end sub
' by typing func
private function function_name()
end function
For public prepend p:
' by typing psub
public sub sub_name()
' Add something here
end sub
' by typing pfunc
public function function_name() as boolean ' Return type will be asked when inserting the snippet
' Add something here
function_name = true
end function
For method with try-catch add e at the end:
' by typing sube
private sub sub_name()
on error goto ErrorHandler
' Add something here
on error goto 0
exit sub
ErrorHandler:
' Handle the exception
end sub
' by typing pfunce ('p' for public, 'func' for function, and 'e' for add error handling)
public function function_name() as boolean ' Return type will be asked when inserting the snippet
on error goto ErrorHandler
' Add something here
function_name = true
on error goto 0
exit function
ErrorHandler:
' Handle the exception
end function
Utilities
Insert a file header (XCode style):
' by typing header
'
' file_name
' current_path
'
' Created by author on current_date.
' Modified by contributor on current_date.
' Copyright © company 2019. All rights reserved.
'
- file_name: automatically inserted.
- current_path: automatically inserted.
- current_date: automatically inserted, only creation date is asked if you need to change it.
Print to output console:
' by typing print
debug.print var_name
' by typing prints
debug.print "string"
Installation
Launch vscode and press [ctrl + p], paste the command below, and press enter.
$ ext install avb
Contributing
Please fork this repository and contribute back using pull requests.
Any contributions, large or small, major features, bugfixes and
integration tests are welcomed and appreciated but will be thoroughly
reviewed and discussed.
You can contact me in the following ways:
Original contributor details:
Links
Original contributor details:
Handy links
Some good documentation on the CLI:
https://vscode-docs.readthedocs.io/en/latest/tools/vscecli/