The following example is function procedure that takes users first name and last name. The values are genetically provided by the user using input box. The function returns users full name on message box.
These are built-in VBScript functions. All you have to do is pass proper values to these function and they will respond as they built for.
| String Functions |
Function Decriptions |
Function Example |
| Asc |
Returns the ASCII character code for the first
character of a string. | document.write(ASC
("ABC")). returns: 65 |
| Chr |
Returns the corresponding character of passed ASCII
code number. | document.write((Chr(65))).
returns: A |
| LCase |
Converts all the characters to
lowercase. | document.write(lcase("CASE")).
returns: case |
| UCase |
Converts all the characters to upper
case. | document.write(Ucase("Case")).
returns: CASE |
| Left |
Returns specified number of characters starting from
left. | document.write(left("language",3)).
returns: lan |
| Right |
Returns specified number of characters staring from
right. |
document.write(Right("language")). returns:
age |
| LTrim |
Removes all the leading spaces from the
string. | document.write(LTrim("far ")).
returns: far, with no spaces |
| RTrim |
Removes all the trailing spaces rom the
string. | document.write(RTrim(" far")).
returns: far, with no spaces |
| Trim | Returns the string argument, with leading and trailing spaced removed. | document.write(Trim(" mid ")). returns: mid, with no spaces. |
| Val | Returns number value of a string. Stops as soon it hits string char. | document.write(Val("22 Maple st.")). returns: 22 |
| String | Takes a number and character code argument and returns the character, repeated a number of times: | document.write(String(3,80)). returns: BBB |
| Date Functions |
| Now() | Returns current system date and time. | document.write(now()). returns: 8/2/02 10:46:33 AM ->with current date & time |
| Date | Returns the current system date in month, day, year format. | document.write(date()). returns: 8/2/02 ->with current date |
| Time | Returns the current system time. | document.write(Time()). returns: 10:11:36 AM ->with current time. |
| Day | Returns the day of the month. | document.write(Day(date)). returns: 9 ->with current day number. |
| Month | Returns the month of the year. | document.write(Month(date)). returns: 9 ->with current month number. |
| MonthName | Returns the name of the specified month. | document.write(MonthName(9)). returns: September |
| WeekDay | Returns number representing the day of the week. | document.write(WeekDay(date)). returns: 6 -> Assuming today is Friday |
| WeekdayName | Returns the name of the specified week day. | document.write(WeekdayName(6)). returns: Friday |
| DateAdd | Adds the specified date or time value to specified date. | document.write(DateAdd("d","10","6-7-02")). returns: 6/17/02 -> Adds 10 days to specified date. d=day, m=month, y=year, h=hour, n=minute |
| Hour, Minute, Second | Returns the number representing hour, minute, second of the day, hour, or minute. | document.write(Hour()). returns: 11 -> Assuming it's the hour is 11. |
| Timer | Returns the number of seconds since 12:00 AM. | document.write(Timer). returns: 40055.84 -> at 11:07 AM |
| TimeSerial | Returns the time for a specific hour, minute, and second converted from military clock. | document.write(TimeSerial(17,30,05)). returns: 5:30:05 PM. |
| TimeValue(time) | Returns the current system time. | document.write(Time(time))returns: 11:18:00 AM -> with current time. |
| FormatDateTime | Returns a formatted date or time. | document.write(FormatDateTime(date)). returns: 8/2/02-> with current date. |
| Number Functions |
| Abs | Returns the absolute value of a number. | document.write(Abs(-5)). returns: 5 | |
| Int | Returns the integer part of a number. | document.write(Int(5.567)). returns: 5 | |
| Fix | Returns the integer part of a number. | document.write(fix(5.567)). returns: 5 | |
| Sqr | Returns square root of a number. | document.write(sqr(25)). returns: 5 | |
| Sgn | Returns 1, 0, or -1 for possitive, zerro or negative number | document.write(Sgn(-22)). returns: -1 | |
| Sin | Returns sine value of a number. | document.write(sin(1)). returns: 0.841470984807897 | |
| Tan | Returns tangent value of a number. | document.write(tan(1)). returns: 1.5574077246549 | |
| Cos | Returns cosine value of a number. | document.write(Cos(1)). returns: 0.54030230586814 | |
| Rnd | Returns random number. | document.write(Rnd). returns: 0.7055475 ->Needs some code to randamize. | |
| Hex | Returns the hexadecimal value of a number. | document.write(Hex(10)). returns: A | |
| Round | Returns rounded number. | document.write(Round(10.888)). returns: 11 | |
| IsNumeric | Returns boolean value [true or false] indicates whether is number or not. | document.write(IsNumeric(10.888)). returns: True | |
| FormatNumber | Returns an expression formatted as a number value. | document.write(FormatNumber(1000.1111,2)).
returns: 1,000.11 |
|
| FormatPercent | Returns an expression formatted as a percent | document.write(FormatPercent(.22)).
returns: 22.00% |
|
| FormatCurrency | Returns an expression formatted as a currency value. | document.write(FormatCurrency(10.888)).
returns: $10.89 |
|
| Other Functions |
| MsgBox | Returns dialog box with specified expression or
arguments. | msgbox"Hello World"
returns: Hello World -> On dialog box. |
|
| | | | |