Welcome to www.programmer2programmer.net Its all about programming


programmer2programmer.net

 Tips
 Microsoft Certification
 Final Year Project Idea NEW
 Connection Strings
 Password Recovery
 SQL Injection
 Encryption & Decryption
  
 LIVE Academic Project
 Project #1 - VB6, Access
  Project #2 - VB.Net, SQL
 Project #3 - ASP, Access
 Project #4 - C#, SQL
 Project #5 - VB6, SQL
 Project #6 - Steganography
 Download MBA Project
  2012 New Projects Ad
  
 University Question Paper and Assignment
 SMU - Question Paper
 SMU - Assignment
 SCDL - Assignment
  
 Interview Question Answer
 General & HR Round
 Visual Basic 6
 VB.Net & C#
 ASP.Net
 SQL Server
  Oracle and DBA NEW
 My SQL
  

100% Tested
Ready Academic IT Projects

BE, ME, BTech, BCA, MCA, MBA, Bsc-IT, MS, BIT, ADIT, DOEACC, IGNOU, SMU
readymadeproject.com
One stop solution for VB6, VB.Net, C#, ASP.Net, Crystal Report, Oracle, SQL Server, MySql, PHP, XML, AJAX ....
Home Personal Member Forum Source Project Tips Contact  
 

 

VB SCRIPT Features : PART - II

  Array handling   Error Handling   Operators
Assignments Expressions Options
Comments Formatting Strings Procedures
Constants/Literals Input/Output Rounding
Control flow Literals Script Engine ID
Conversions Math Strings
Dates/Times Miscellaneous Variants
Declarations Objects

You can find here comprehensive features of VB Script, you may find these features are very much common with Visual Basic languages for both VB 6 and VBA. Quick Link Part  I   II  III   IV   V

 

Category

Keywords

Conversions

Abs
- Returns the absolute value of a number.

Dim MyNumber

MyNumber = Abs(50.3)  ' Returns 50.3.

MyNumber = Abs(-50.3) ' Returns 50.3.

 

Asc
- Returns the ANSI character code corresponding to the first letter in a string.

Dim MyNumber

MyNumber = Asc("A")       ' Returns 65.

MyNumber = Asc("a")       ' Returns 97.

MyNumber = Asc("Apple")   ' Returns 65.

 

Chr
-Returns the character associated with the specified ANSI character code.

Dim MyChar
MyChar = Chr(65)   ' Returns A.

MyChar = Chr(97)   ' Returns a.

MyChar = Chr(62)   ' Returns >.

MyChar = Chr(37)   ' Returns %.

 

CBool
- Returns an expression that has been converted to a Variant of subtype Boolean.

Dim A, B, Check

A = 5: B = 5           ' Initialize variables.

Check = CBool(A = B)   ' Check contains True.

A = 0                  ' Define variable.

Check = CBool(A)       ' Check contains False.

 

CByte
-Returns an expression that has been converted to a Variant of subtype Byte.

Dim MyDouble, MyByte

MyDouble = 125.5678        ' MyDouble is a Double.

MyByte = CByte(MyDouble)   ' MyByte contains 126.

 

Ccur
-Returns an expression that has been converted to a Variant of subtype Currency

Dim MyDouble, MyCurr

MyDouble = 543.214588         ' MyDouble is a Double.

MyCurr = CCur(MyDouble * 2)   ' Convert result of MyDouble * 2 (1086.429176) to a Currency (1086.4292).

CDate
-Returns an expression that has been converted to a Variant of subtype Date.

MyDate = "October 19, 1962"   ' Define date.

MyShortDate = CDate(MyDate)   ' Convert to Date data type.

MyTime = "4:35:47 PM"         ' Define time.

MyShortTime = CDate(MyTime)   ' Convert to Date data type. 

 

CDbl
-Returns an expression that has been converted to a Variant of subtype Double.
 

Dim MyCurr, MyDouble

MyCurr = CCur(234.456784)              ' MyCurr is a Currency (234.4567).

MyDouble = CDbl(MyCurr * 8.2 * 0.01)   ' Convert result to a Double (19.2254576).

 

CInt
-Returns an expression that has been converted to a Variant of subtype Integer.

Dim MyDouble, MyInt

MyDouble = 2345.5678     ' MyDouble is a Double.

MyInt = CInt(MyDouble)   ' MyInt contains 2346.

 

CLng
- Returns an expression that has been converted to a Variant of subtype Long.

Dim MyVal1, MyVal2, MyLong1, MyLong2

MyVal1 = 25427.45: MyVal2 = 25427.55   ' MyVal1, MyVal2 are Doubles.

MyLong1 = CLng(MyVal1)   ' MyLong1 contains 25427.

MyLong2 = CLng(MyVal2)   ' MyLong2 contains 25428.

 

CSng
- Returns an expression that has been converted to a Variant of subtype Single.

Dim MyDouble1, MyDouble2, MySingle1, MySingle2   ' MyDouble1, MyDouble2 are Doubles.

MyDouble1 = 75.3421115: MyDouble2 = 75.3421555

MySingle1 = CSng(MyDouble1)   ' MySingle1 contains 75.34211.

MySingle2 = CSng(MyDouble2)   ' MySingle2 contains 75.34216.

 

CStr
- Returns an expression that has been converted to a Variant of subtype String.

Dim MyDouble, MyString

MyDouble = 437.324         ' MyDouble is a Double.

MyString = CStr(MyDouble)   ' MyString contains "437.324".

DateSerial
- Returns a Variant of subtype Date for a specified year, month, and day

Dim MyDate1, MyDate2

MyDate1 = DateSerial(1970, 1, 1)   ' Returns January 1, 1970.

MyDate2 = DateSerial(1990 - 10, 8 - 2, 1 - 1)' Returns May 31, 1980.

DateValue
- Returns a Variant of subtype Date.

Dim MyDate

MyDate = DateValue("September 11, 1963")   ' Return a date.

 

Hex
- Returns a string representing the hexadecimal value of a number.

Dim MyHex

MyHex = Hex(5)   ' Returns 5.

MyHex = Hex(10)   ' Returns A.

MyHex = Hex(459)   ' Returns 1CB.

 

Oct
- Returns a string representing the octal value of a number.

Dim MyOct

MyOct = Oct(4)     ' Returns 4.

MyOct = Oct(8)     ' Returns 10.

MyOct = Oct(459)   ' Returns 713.

 

Fix
- Returns the integer portion of a number.

MyNumber = Int(99.8)    ' Returns 99.

MyNumber = Fix(99.2)    ' Returns 99.

MyNumber = Int(-99.8)   ' Returns -100.

MyNumber = Fix(-99.8)   ' Returns -99.

MyNumber = Int(-99.2)   ' Returns -100.

MyNumber = Fix(-99.2)   ' Returns -99.

 

Int
- Returns the integer portion of a number.

Sgn
- Returns an integer indicating the sign of a number.

Dim MyVar1, MyVar2, MyVar3, MySign

MyVar1 = 12: MyVar2 = -2.4: MyVar3 = 0

MySign = Sgn(MyVar1)   ' Returns 1.

MySign = Sgn(MyVar2)   ' Returns -1.

MySign = Sgn(MyVar3)   ' Returns 0.

 

TimeSerial
- Returns a Variant of subtype Date containing the time for a specific hour, minute, and second.

Dim MyTime1

MyTime1 = TimeSerial(12 - 6, -15, 0) ' Returns 5:45:00 AM.

TimeValue
- Returns a Variant of subtype Date containing the time.

Dim MyTime

MyTime = TimeValue("4:35:17 PM")   ' MyTime contains 4:35:17 PM.

 

Dates/Times

Date
- Returns the current system date.

Dim MyDate

MyDate = Date   ' MyDate contains the current system date.

 

Time
- Returns a Variant of subtype Date indicating the current system time.

Dim MyTime

MyTime = Time   ' Return current system time.

DateAdd
- Returns a date to which a specified time interval has been added.

NewDate = DateAdd("m", 1, "31-Jan-95") 'returns 28-Feb-95

 

DateDiff
- Returns the number of intervals between two dates.

DiffADate = "Days from today: " & DateDiff("d", Now, theDate)

 

DatePart
 - Returns the specified part of a given date.

GetQuarter = DatePart("q", TheDate)

 

Day
- Returns a whole number between 1 and 31, inclusive, representing the day of the month.

Dim MyDay

MyDay = Day("October 19, 1962")   ' MyDay contains 19.

 

Month
- Returns a whole number between 1 and 12, inclusive, representing the month of the year.

Dim MyVar

MyVar = Month(Now) ' MyVar contains the number corresponding to

                   ' the current month.

 

MonthName
- Returns a string indicating the specified month.

Dim MyVar

MyVar = MonthName(10, True) ' MyVar contains "Oct".

 

Weekday
- Returns a whole number representing the day of the week.

Dim MyDate, MyWeekDay

MyDate = #October 19, 1962#   ' Assign a date.

MyWeekDay = Weekday(MyDate)   ' MyWeekDay contains 6 because MyDate represents a Friday.

 

WeekdayName
- Returns a string indicating the specified day of the week.

Dim MyDate

MyDate = WeekDayName(6, True)   ' MyDate contains Fri.

 

Year
- Returns a whole number representing the year.

Dim MyDate, MyYear

MyDate = #October 19, 1962#   ' Assign a date.

MyYear = Year(MyDate)         ' MyYear contains 1962.

 

Hour
- Returns a whole number between 0 and 23, inclusive, representing the hour of the day.

Dim MyTime, MyHour

MyTime = Now

MyHour = Hour(MyTime) ' MyHour contains the number representing 

                      ' the current hour.

 

Minute
- Returns a whole number between 0 and 59, inclusive, representing the minute of the hour.

Dim MyVar

MyVar = Minute(Now) 

 

Second
-Returns a whole number between 0 and 59, inclusive, representing the second of the minute.

Dim MySec

MySec = Second(Now)

   ' MySec contains the number representing the current second.

 

Now
- Returns the current date and time according to the setting of your computer's system date and time.

Dim MyVar

MyVar = Now ' MyVar contains the current date and time.

 

Declarations

Class
- Declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.

Class Myclass

   ‘statements

End Class

 

Const
- Declares constants for use in place of literal values.

Const MyVar = 459   ' Constants are Public by default.

Private Const MyString = "HELP"   ' Declare Private constant.

Const MyStr = "Hello", MyNumber = 3.4567   ' Declare multiple constants on same line.

 

Function
- Declares the name, arguments, and code that form the body of a Function procedure.

Function MyFunction(a,b)

   MyFunction = a+b

End Function

 

Sub
- Declares the name, arguments, and code that form the body of a Sub procedure.

Sub HelloWorld()

   MsgBox “Hello World”

End Sub

 

Property Get
- Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that gets (returns) the value of a property.

Property Let
- Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that assigns (sets) the value of a property.

Property Set
- Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that sets a reference to an object.

VB Script Features quick Link PART I   II  III   IV   V

Next Topics   3.   VBScript Data Types
C) Atanu Maity, 2006-2007