VBScript functionality

Author Message
TNO

  • Total Posts : 2094
  • Scores: 36
  • Reward points : 0
  • Joined: 12/18/2004
  • Location: Earth
  • Status: offline
VBScript functionality Saturday, October 29, 2005 7:20 PM (permalink)
0
This may be a little blasphemous in a vbscript forum but here it goes:

Here is a compilation/creation/collection of recreated vbscript functions for use in JavaScript. This will be helpful to those (like myself). Who try to use the best of both worlds in their projects. This will also help those unfamiliar with the language to simplify some more complex problems.

Here's a quick overview of the contents:






CreateObject(x)
Translates into: new ActiveXObject(x)

dateDiff(p_Interval, p_Date1, p_Date2,p_firstdayofweek, p_firstweekofyear)
Returns the number of intervals between two dates

datePart(p_Interval, p_Date,p_firstdayofweek, p_firstweekofyear)
Returns the specified part of a given date.

FormatCurrency(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

FormatDateTime(datetime, FormatType)

FormatNumber(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

FormatPercent(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

InStr(strSearch,charSearchFor)
Returns the first location a substring SearchForStr that was found in the string str

isDate(p_Expression)

Left(string, length)
Returns a specified number of characters from the left side of a string.

Len(str)
Returns the number of characters in a string.

LTrim(str)
Returns a copy of a string without leading spaces.

Mid(str,start,len)
Returns a specified number of characters from a string.
monthName(p_Date, p_abbreviate)

Now()
Returns the current date and time.

Right(string, length)
Returns a specified number of characters from the right side of a string

RTrim(string)
Returns a copy of a string without trailing spaces.

StrReverse(strInput)
Returns the reverse of a string.

Trim(strInput)
Removes leading and trailing spaces

weekdayName(p_Date, p_abbreviate)






<Updated library below>
<message edited by TNO on Wednesday, October 18, 2006 11:02 PM>
To iterate is human, to recurse divine. -- L. Peter Deutsch
 
#1
    TNO

    • Total Posts : 2094
    • Scores: 36
    • Reward points : 0
    • Joined: 12/18/2004
    • Location: Earth
    • Status: offline
    RE: VBScript functionality Wednesday, October 18, 2006 10:58 PM (permalink)
    0
    I almost forgot about my ancient post here. Figured its time for an update of some sort:

    //version: 1.01 updates in red

    CreateObject(x)
    Translates into: new ActiveXObject(x)

    dateAdd(p_Interval, p_Number, p_Date) <--Supports Milliseconds!!!

    dateDiff(p_Interval, p_Date1, p_Date2,p_firstdayofweek, p_firstweekofyear) <--Supports Milliseconds!!!
    Returns the number of intervals between two dates

    datePart(p_Interval, p_Date,p_firstdayofweek, p_firstweekofyear)
    Returns the specified part of a given date.

    FormatCurrency(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

    FormatDateTime(datetime, FormatType)

    FormatNumber(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

    FormatPercent(Expression, NumDigitsAfterDecimal,IncludeLeadingDigit,UseParensForNegativeNumbers, GroupDigits)

    InStr(strSearch,charSearchFor)
    Returns the first location a substring SearchForStr that was found in the string str

    isDate(p_Expression)

    Left(string, length)
    Returns a specified number of characters from the left side of a string.

    Len(str)
    Returns the number of characters in a string.

    LTrim(str)
    Returns a copy of a string without leading spaces.

    Mid(str,start,len)
    Returns a specified number of characters from a string.
    monthName(p_Date, p_abbreviate)

    monthName(p_Date, p_abbreviate)

    Now()

    Returns the current date and time.

    Right(string, length)
    Returns a specified number of characters from the right side of a string

    RTrim(string)
    Returns a copy of a string without trailing spaces.

    StrReverse(strInput)
    Returns the reverse of a string.

    Trim(strInput)
    Removes leading and trailing spaces

    weekdayName(p_Date, p_abbreviate)

    If there is functionality you'd like to see added to this library let me know!
    <message edited by TNO on Wednesday, October 18, 2006 11:00 PM>
    Attachment(s)Attachments are not available: Download requirements not met
    To iterate is human, to recurse divine. -- L. Peter Deutsch
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9