Coding Tips (JavaScript/CSS/VBA/Win32)

Useful code snippets, tips and some Windows applications
Bookmark this page

Top 5 pages

Hide Table Rows
VBA Functions
JavaScript Formatting Functions
C++ Tips
Excel VBA Functions

This site contains some useful tips and snippets in JavaScript/CSS, VBA and C/C++.

Download My Style 2.1 Add-On For Internet Explorer You can create your own style for web pages that you view in the Internet Explorer browser.

You can customize a web page in several ways:

Assign Class Name to Page Elements

The following JavaScript function allows you assign CSS class selectors to page elements dynamically. It acceps two arguments: an element name and a style selector name.
function assignClass(elName, selector){
        var elements = document.getElementsByTagName(elName);
        var len  = elements.length;
        while(len-->0){
            elements[len].className=selector;
        }
    }
Usage: window.onload= function(){assignClass("td", "selectorName");};

First, the code finds all the page elements with a given name. Then it loops through each elements and assigns it the selector passed as the second argument.

More Tips and Scripts

View Cookies On Your Right-Click
A script that adds a context menu item to view cookes in Internet Explorer
Convert Text To Input
Use JavaScript and DOM to edit text in place
Compact script to calculate JavaScript execution time

Put Messages on the HTML Page

No need to use alert to display messages. Put them on the page using this function.
IE Context Menu Installer
Add a capability to color and google search on selected text in Internet Explorer.
Alternate table rows
Use this simple script to create alternate background color for HTML table rows.
Customize the way websites look in Internet Explorer
Use your own script to adjust line spacing and margins on web pages.
Bookmarklets (JavaScript Favelets)
Bookmarklets to reduce any web page margins.
JavaScript Extract File Name
A short Javascript function to extract a file name from a path.
Search HTML Table
The script will search an HTML table and highlight table cells containing the search text.

Online Work Days Calculator
The script calculates the number of work (week) days in any given month from 2005 to 2015
How To Manipulate HTML Table Rows with DHTML
Add and remove rows
Hide and show rows
Expand and collapse text
JavaScript/CSS Tips
How to prevent the Enter button from submitting the form in Internet Explorer
How to keep the focus on an invalid field
Highlight text-box background color
Make a text-box read-only
Javascript Cookies
How to use cookies to remember values typed into a text box
JavaScript Backslash Function
A Javascript function to insert a backslash before a double quote.
How To Send Email to LotusNotes from Excel
An Excel procedure
How To Use String Tables in Win32
A short article on how to use string tables to localize Win32 applications.
Word/VBA Functions
A Word VBA function to format an embedded image to fit a required width. The function will format all images in the document.
A function to return the directory name based on a file path.
Functions to insert and delete a menu item.
FileList Application
An application that makes a flat list of files in a folder and its subfolders and much more...
I use it to easily find the latest modified files in the folder tree and to find files by extension , something that is difficult to do with the Windows search function.

Mp3 CD Collector
An application that creates an inventory of mp3 files from CDs or the local drive.
Collections of mp3 files can be saved as separate files.

Random Play
An application that selects 10 mp3 files at random and plays them in Winamp if it is present on the system.
Temperature Converter
A very simple application to convert temperature, distance and area measurements from the metric to the North-American system

C++ Tips

A simple tokenize function
Write a number to a string
Replace vector elements
Win32 Tips
Tips and samples for coding with Win32 SDK, no MFC required.
Compile Error RC2144
A possible solution to a RC2144 compile error (Win32)
Create your own Oracle function
A tip on how to create a simple function in Oracle and how to reproduce the functionality with a built-in decode function
Modify Folders in Open/Save Dialog
What is the registry location to modify folders for standard Open/Save Dialog