When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
VBScript-to-JavaScript Functions


Many web developers enjoy using VBScript, due to its many nice, inherent functions. However, Internet Explorer is the only browser which supports VBScript, so for production web applications it is essential that all client-side scripting be written in JavaScript.

No problem, though, we can write VBScript - like functions in JavaScript! Below you'll find a number of VBScript functions implemented in JavaScript. If you decide to use any of these (which I hope you do), please simply include the below lines of text in the JavaScript code, and drop me an email giving me the URL of your site, so I can see your hard work.

     // JavaScript Functions Written by:
     //    Scott Mitchell
     //    mitchell@4guysfromrolla.com
     //    http://www.4GuysFromRolla.com


FormatNumber(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UserParensForNegativeNumbers, GroupDigits) Returns an expression formatted as a number.
FormatPercent(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UserParensForNegativeNumbers, GroupDigits) Returns an expression formatted as a percentage (multiplied by 100) with a trailing % character.
FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UserParensForNegativeNumbers, GroupDigits) Returns an expression formatted as a currency value.
FormatDateTime(Date, FormatType) Returns an expression formatted as a date or time.
LTrim(string) Returns a string without leading spaces
RTrim(string) Returns a string without trailing spaces
Trim(string) Returns a string without leading and trailing spaces
Len(string) Returns the length of the specified string.
Left(string, length) Returns a specified number of characters from the left side of a string.
Right(string, length) Returns a specified number of characters from the right side of a string.
Mid(string, start, length) Returns a specified number of characters from a string.
InStr(strSearch, charSearchFor) Returns the position of the character charSearchFor in strSearch


ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article