Write Your Own VBScript HTA Text Editor
By Stephen Bucaro
Visual Basic (VB) is a very popular programming language because it is easily understood by humans.
VBScript in interpreted Visual Basic, in other words the code is executed on the fly one statement
at a time rather than compiled before hand. In this article, I'll show you how to write your own
text editor application.
HTA stands for HTML Application. Basically you design your application as a webpage. To develop your
application you can use a text editor like windows Notepad. Your source code consists of HTML, Dynamic HTML,
generate the user interface, and the scripting language is used for the program logic.
A regular HTML file restricted to the security level of the web browser. You can't read or write files to
the user's computer. You can use HTML5's storage API to store data, and read and write cookies in the browser.
But once you change the file extension to .hta, it executes as a "fully trusted" application. An HTA can
write, edit and delete files and registry entries.
How The HTA Text Editor Works
Because this application is designed for instructional purposes, I didn't design it with the conventional
[File] drop-down menu. In order to show how menu items link to the code that performs each function, I just
placed all the menu selections in the main menu. Another non-conventional action is when you [Open] an
existing file, it does not not display the files contents, you have to click the [Read] menu item to display
the files contents. That's so, for instructional purposes, I can keep the file loading code separate from
the file contents displaying code.
I have not included the complexity of directory navigation, [New] creates a new text file in current folder
(the same folder application resides in), [Open] Lists text files in current folder, [Write] writes edited
text back to the same file.
In case you're not familiar with the basic structure of an HTML document, I'll give you a brief introduction
here. An HTML document consists of tags that divide the document into two sections, the head and
the body. These tags are shown below.
In the head section, that is between the <head> and </head> tags is where you place
Cascading Style Sheets (CSS) code and your VBScript code. The head section is shown below.