18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

Cos<br />

Description Returns the cosine of an angle.<br />

Usage realVal = Cos(number)<br />

Arguments number<br />

The number argument can be any valid numeric expression that expresses an angle in radian<br />

Return Returns the cosine of an angle as a Variant subtype Double. Result is in radians.<br />

Remarks The Cos function takes an angle and returns the ratio of two sides of a right triangle. The ratio is<br />

the length of the side adjacent to the angle divided by the length of the hypotenuse. The result<br />

lies in the range -1 to 1. To convert degrees to radians, multiply degrees by pi /180. To convert<br />

radians to degrees, multiply radians by 180/pi.<br />

See also Atn, Sin, and Tan<br />

Example Dim MyAngle, MySecant<br />

MyAngle = 1.3 ' Define angle in radians.<br />

MySecant = 1 / Cos(MyAngle) ' Calculate secant.<br />

Angle = (30 * 3.14159/180) ‘ Convert 30 degrees into radians<br />

AngleCos = Cos(Angle) ‘ Compute cosine of angle<br />

CreateObject<br />

Description Creates and returns a reference to an Automation object.<br />

Usage Set objName = CreateObject(servername.typename [, location])<br />

Arguments servername<br />

Required. The name of the application providing the object.<br />

typename<br />

Required. The type or class of the object to create.<br />

location<br />

Optional. The name of the network server where the object is to be created.<br />

Return An object reference<br />

Remarks The servername and typename together are often referred to as a ProgID, or Programmatic ID. A<br />

ProgID may actually have multiple parts (e.g. servername.typename.version)To avoid confusion,<br />

note that the parameter servername refers to a Microsoft COM server (automation server)<br />

applications such as Microsoft Access, Excel, Word. Other COM servers such as ADO.NET can<br />

be referenced. Automation servers provide at least one type of object. For example, a wordprocessing<br />

application may provide an application object, a document object, and a toolbar object.<br />

To create an Automation object, assign the object returned by CreateObject to an object<br />

variable. This code starts the application that creates the object (in this case, a Microsoft Excel<br />

spreadsheet).<br />

Dim ExcelSheet<br />

Set ExcelSheet = CreateObject("Excel.Sheet")<br />

Once an object is created, refer to it in <strong>VBScript</strong> code using the object variable you defined. As<br />

shown in the following example, you can access properties and methods of the new object using<br />

the object variable, ExcelSheet, and other Excel objects, including the Application object and the<br />

ActiveSheet.Cells collection.<br />

ExcelSheet.Application.Visible = True ' Make Excel object. visible<br />

ExcelSheet.ActiveSheet.Cells(1,1).Value = "ABC" ‘ Place text in row 1, col 1<br />

ExcelSheet.SaveAs "C:\DOCS\TEST.XLS" ' Save the sheet.<br />

ExcelSheet.Application.Quit ‘ Close Excel<br />

Set ExcelSheet = Nothing ' Release the object variable.<br />

Creating an object on a remote server can only be accomplished when Internet security is turned<br />

off. You can create an object on a remote networked computer by passing the name of the<br />

computer to the servername argument of CreateObject. That name is the same as the machine<br />

name portion of a share name. For a network share named "\\myserver\public", the servername is<br />

"myserver". In addition, you can specify servername using DNS <strong>for</strong>mat or an IP address.<br />

122 <strong>InduSoft</strong>, Ltd.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!