Archives de catégorie : Scripting

vbscript – LCase / UCase

**FUNCTION:** `LCase(string) / UCase(string)`

**Description**
Convertit une chaîne en minuscules (`LCase`) ou majuscules (`UCase`).

**Syntax**
`LCase(string) / UCase(string)`

**Paramètres**
– `string` : Chaîne source.

**Retour**
Chaîne convertie.

**Exemples**
« `vb
WScript.Echo LCase(« ABC »)
WScript.Echo UCase(« abc »)
« `

**Output :** `abc ; ABC`

**Voir aussi**
`StrComp`, `Replace`

vbscript – WScript.Arguments

**PROPERTY:** `WScript.Arguments`

**Description**
Accès aux arguments de ligne de commande.

**Syntax**
`WScript.Arguments`

**Paramètres**
– *(aucun)*

**Retour**
Objet `WScript.Arguments`.

**Exemples**
« `vb
Dim i
For i = 0 To WScript.Arguments.Count – 1
WScript.Echo i & « :  » & WScript.Arguments(i)
Next
« `

**Voir aussi**
`WScript.Arguments.Count`, `WScript.Arguments.Item`

vbscript – IsNumeric

**FUNCTION:** `IsNumeric(expression)`

**Description**
Indique si une expression est convertible en nombre.

**Syntax**
`IsNumeric(expression)`

**Paramètres**
– `expression` : Valeur/chaîne à tester.

**Retour**
`True` ou `False`.

**Exemples**
« `vb
WScript.Echo IsNumeric(« 12.3 »)
WScript.Echo IsNumeric(« 12a »)
« `

**Output :** `True ; False`

**Voir aussi**
`CDbl`, `CInt`, `CLng`

vbscript – WshShell.Run

**METHOD:** `shell.Run(command[, windowStyle[, waitOnReturn]])`

**Description**
Exécute une commande/programme.

**Syntax**
`shell.Run(command[, windowStyle[, waitOnReturn]])`

**Paramètres**
– `command` : Commande (ex: « notepad.exe » ou « cmd /c dir »).
– `waitOnReturn` : `True` pour attendre la fin.

**Retour**
Code retour si `waitOnReturn=True`, sinon 0 (selon contexte).

**Exemples**
« `vb
Dim shell
Set shell = CreateObject(« WScript.Shell »)
shell.Run « notepad.exe », 1, False
« `

**Voir aussi**
`WshShell.Exec`, `WshShell.Popup`

vbscript – CDate

FUNCTION:  CDate( )


Implemented in version 1.0

You can determine the expression subtype by using the function VarType( ).

CDate(Date)

The CDate function converts any valid date and time expression to the variant of subtype Date.

The default date output will be of the format:  **/**/** The default time output will be of the format:  **:**:** *M Converted date values can range from January 1, 100 to December 31, 9999

Code:
<% anydate = « June 26, 1943 » %>
<% =CDate(anydate) %>

Output:
6/26/43

Code:
<% anydate = #6/26/43# %>
<% =CDate(anydate) %>

Output:
6/26/43

Code:
<% anytime= »2:23:59 PM » %>
<% =CDate(anytime) %>

Output:
2:23:59 PM

vbscript – CCur

FUNCTION: CCur( )


Implemented in version 1.0

You can determine the expression subtype by using the function VarType( ).

CCur(Number)

The CCur function converts any number or numeric string to the variant of subtypeCurrency.

Converts to currency values ranging from
-922,337,203,685,477.5808 to 922,337,203,685,477.5807

Code:
<% anynumber=(12345) %>
<% =CCur(any_number) %>

Output:
12345

Code:
<% any_numeric_string=(« 98765 ») %>
<% =CCur(any_numeric_string) %>

Output:
98765

This function rounds off to 4 decimal places.

Code:
<% anynumber=(55555.123456) %>
<% =CCur(anynumber) %>

Output:
55555.1235

vbscript – CByte

FUNCTION:  CByte( )


Implemented in version 1.0

You can determine the expression subtype by using the function VarType( ).

CByte(Number)

The CByte function converts any number between 0 and 255 to the variant of subtypeByte.

Code:
<% anynumber=(9.876) %>
<% =CByte(anynumber) %>

Output:
10

Code:
<% anynumber=(255) %>
<% =CByte(anynumber) %>

Output:
255

vbscript – CBool

FUNCTION:  CBool( )


Implemented in version 1.0

You can determine the expression subtype by using the function VarType( ).

CBool(Number)

The CBool function converts any number to the variant of subtype Boolean.

The output for Boolean is either true or false. If the conversion is successful, the output will be true. If the conversion fails, the output will be false or an error message.

Code:
<% anynumber=7.77 %>
<% =CBool(anynumber) %>

Output:
True

Code:
<% notnumber=abc %>
<% =CBool(notnumber) %>

Output:
False

vbscript – Call

STATEMENT:  Call


Implemented in version 1.0

Call

The Call statement can be used for calling a function or subroutine.

Note that the use of Call is optional. In other words, you can call a function or subroutine by simply stating the function’s or subroutine’s name. If you use Call and if there are one or more arguments to be passed you must enclose all of the arguments in parentheses. If you do not use Call, do not use the parentheses.

If you use Call to call a function, the return value of the function is discarded.

Code:
<% Call afunction %>

<% afunction %>

<% Call myfunction(myvar1, myvar2, mystring, myarray) %>

<% myfunction myvar1, myvar2, mystring, myarray %>

<% Call anysubroutine(anum, astring) %>

<% anothersubroutine %>