« Programmation VBScript/Introduction » : différence entre les versions

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
Bring Your Look Combined With Jewellery
m Révocation des modifications de 112.111.185.48 (discussion) vers la dernière version de JackPotte
Ligne 1 : Ligne 1 :
'''VBScript''' ou '''VBS''' (Visual Basic Script) est un langage parsé par les interpréteurs supportant le '''WSH''' de microsoft.
The following tips will allow you to decide the best expensive jewelry purchases for you personally. We've basic this process by providing you information you should use about buying stunning precious jewelry. Buying jewelry will allow you to create a adornment assortment which enables a statement. Or it could be a amazing long lasting expenditure. The advise offered in this post should help you in the choice process.


*Sur client : < script langage="VBScript" />
A precious stone which has a fluorescence of light blue when subjected to an sun light, also called a dark gentle, means that the gemstone can look whiter within the daylight which could mask any yellow tints the gemstone may have. This really is valuable when selecting a diamond for the reason that diamond will appear much brighter, even though it has a reduced colour grade.
*Sur serveur : <% script langage="VBScript" %>


The size of your expensive jewelry pertaining to that of your body is extremely important in producing the right general stability and artistic. For example, if you have a petite construct, will not wear huge components of jewellery as they will not likely supplement your figure or put in your attire in the optimistic way.


= Opérateurs =
In order to save money when purchasing precious jewelry, avoid the huge names. These jewelers pay out big dollars to advertise their labels and move that cost to the customer. You can often locate premium quality expensive jewelry that does not have the "large brand" connected to it for a small part of the price.
{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| + || addition
|- align=center bgcolor="#EFEFEF"
| - || soustraction
|- align=center
| * || multiplication
|- align=center bgcolor="#EFEFEF"
| ^ || puissance
|- align=center
| / || division à float
|- align=center bgcolor="#EFEFEF"
| \ || division entière
|- align=center
| mod || modulo - reste de la division entière
|- align=center bgcolor="#EFEFEF"
| < || plus petit
|- align=center
| <= || plus petit ou égal
|- align=center bgcolor="#EFEFEF"
| > || plus grand
|- align=center
|>= || plus grand ou égal
|- align=center bgcolor="#EFEFEF"
| <> || différent
|- align=center
| not || non logique
|- align=center bgcolor="#EFEFEF"
| and || et logique
|- align=center
| or || ou logique
|- align=center bgcolor="#EFEFEF"
| xor || xor logique
|- align=center
| eqv || equivalence
|- align=center bgcolor="#EFEFEF"
| imp || implication
|- align=center
| & || concaténation
|}


== Déclarations ==
A comparatively latest well-liked pattern is definitely the go up from the "feeling diamond ring" or other this kind of indicative jewelry, often made out of liquefied crystals that transform their shade responding to alterations in physique temp. They are rather well-known specifically amid kids and adolescents, and can complement many garments because of the shifting coloration.


Contrairement à beaucoup d'autres langages, le '''vbs''' n'est pas sensible à la casse.
The ideas which were provided must improve your personal-self-confidence when it comes to jewellery acquiring and treatment. You now determine what factors to consider concerning expensive jewelry, and achieving the skills should also provide you with the potential to talk to any jeweler with certainty.
--------------------------------
*LÉGENDE
:src - source
:nm - nom
:var - variable
:expr - expression
:ins - instruction
:arg - argument
:cond - condition
---------------------------------
* Déclaration
:'''option explicit''' - ''force déclaration de toutes variables dans scr''

:'''dim''' nm(src) - ''variable''

:'''redim''' [preserve] var(src)

:'''const''' nm=expr - ''constante''

* Procédure - ''execute instructions''
:'''sub''' nm(arg1,arg2,...)
::[ins]
::'''[exit sub]'''
::[ins]
:'''end sub'''

* Fonction - ''retourne une valeur en sortie à nm''
:'''function''' nm(arg1,arg2,...)
::[ins]
::[nm=expr]
::'''[exit function]'''
::[ins]
::[nm=expr]
:'''end function'''

* Get - ''comme fonction simple''
:'''property get''' nm(arg1,arg2,...) '''as''' [type]
::...
::[ins]
::[nm=expr]
:'''end property'''

* Let - ''comme fonction simple''
:'''property let''' nm(arg1,arg2,...)
::...
::[ins]
:'''end property'''
* Set - comme fonction simple
:'''property set''' nm(arg1,arg2,...)
::...
::[ins]
:'''end property'''
* Classe - ''retourne initialize || terminate''
:'''class ClassName'''
:::[var]
::Private Sub Class_Initialize()
:::[ins]
::End Sub
::Private Sub Class_Terminate()
:::[ins]
::End Sub
::Public Function NomMethode([arg])
:::[ins]
::End Function
:'''end Class'''
-----------------------------------------------------------

<code>
'''nota''' : const/sub/function/property sont déclarables en [public [default] | private]
:ex 1
::public function nm(args) - pour toute la src
:ex 2
::sub nm(args)
:::private const=expr - ''n'est déclarée et n'est valable que dans la procédure''
::end sub</code>

== Instructions de contrôle ==

*TEST
<pre>
If cond Then [ins] Else [ins]
</pre>
<pre>
If cond1 Then
[ins]
Elseif cond2 Then
[ins]
Else
[ins]
Endif
</pre>
<pre>
Select Case expression
Case expr1
[ins]
Case expr2
[ins]
Case Else
[ins]
End Select
</pre>
*BOUCLE
<pre>
For cpt = début To fin [Step pas]
[ins]
[Exit For]
[ins]
Next [cpt]
</pre>
<pre>
For Each élément In groupe
[ins]
[Exit For]
[ins]
Next élément
</pre>
<pre>
Do [{While | Until} condition]
[ins]
[Exit Do]
[ins]
Loop
</pre>
<pre>
Do
[ins]
[Exit Do]
[ins]
Loop [{While | Until} condition]
</pre>
<pre>
While condition
[ins]
Wend
</pre>
*APPELS
<pre>
With obj
[ins]
End Width
</pre>
<pre>
Call nom [args]
</pre>
*ERREURS
<pre>
On Error Resume Next
On Error Goto 0
</pre>
*REMARQUES
<pre>
Rem
</pre>
*AFFECTATION DE REFERENCES
<pre>
Set objvar=[obj expr | New classname | Nothing ]
</pre>
*ASSOCIATION DE REFERENCE
<pre>
Set object.eventname=GetRef(procname)
</pre>

= Fonctions =
== conversion et mise en forme ==
*CBool(expr) - ''conversion en variant booleen''
*CByte(expr) - ''conversion en variant byte''
*CCur(expr) - ''conversion en variant currency''
*CDate(expr) - ''conversion en variant date''
*CDbl(expr) - ''conversion en variant double''
*CInt(expr) - ''conversion en variant integer''
*CLng(expr) - ''conversion en variant long''
*CSng(expr) - ''conversion en variant single''
*CStr(expr) - ''conversion en variant string''
*FormatCurrency(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - ''conversion formatée en variant currency''
*FormatDateTime(date,[NamedFormat]) - ''conversion formatée en variant date''
*FormatNumber(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - ''conversion formatée en variant nombre''
*FormatPercent(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - ''conversion formatée en variant percent''
*Hex(nbr) - ''conversion en variant hexadecimal''
*IsArray(expr) - ''renvoit booleen si tableau''
*IsDate(expr) - ''renvoit booleen si date''
*IsEmpty(expr) - ''renvoit booleen si vide''
*IsNull(expr) - ''renvoit booleen si null''
*IsNumeric(expr) - ''renvoit booleen si nbr''
*IsObject(identifier) - ''renvoit booleen si obj automation''
*Oct(nbr) - ''conversion en string octal''

== mathématiques ==
*Abs(nbr) - ''renvoie valeur absolue''
*Atn(nbr) - ''renvoie arc tangent''
*Cos(nbr) - ''renvoie cosinus''
*Exp(nbr) - ''renvoie la puissance''
*Int(nbr) - ''renvoie partie entière''
*Fix(nbr) - ''renvoie partie entière''
*Log(nbr) - ''renvoie log népérien''
*Sqr(nbr) - ''renvoie racine carrée''
*Tan(nbr) - ''renvoie tangente''
*Sgn(nbr) - ''renvoie signe''
*Randomize(nbr) - ''init nbr aleatoire !!les nombres ne sont pas aleatoire en vbs!!''
*Rnd(nbr) - ''renvoie nbr aleatoire''
*Round(expr,[numdecimalplaces]) - ''renvoie l'arrondi''
*Sin(nbr) - ''renvoie sinus''

== de traitement de chaînes ==
*Asc(string) - ''renvoie code ansi du 1er char''
*Chr(charcode) - ''renvoie le char du code ansi''
*inStr(start,string,string2,[compare]) - ''renvoie 1ère position d'un string dans un autre''
*InStrRev(delimiter) - ''renvoie position d'un string dans un autre en partant de fin''
*Join(string) - ''renvoie string joins partant d'un tableau''
*LCase(string) - ''conversion en minuscule''
*Left(string,length) - ''renvoie sous string partant de gauche''
*Len(string) - ''renvoie nbr de char dans string''
*LTrim(string) - ''renvoie string sans espace à gauche''
*Mid(string,start,[length]) - ''renvoie sous string partant de milieu''
*Replace(expr,find,replacement,[start],[count],[compare]) - ''remplace string dans string''
*Right(string,length) - ''renvoie sous string partant de droite''
*RTrim(string) - ''renvoie string sans espace à droite''
*StrComp(string1,string2,[compare]) - ''renvoie valeur de comparaison de string''
*String([nbr],[char]) - ''renvoie string de char repete''
*StrReverse(string) - ''renvoie string inverse''
*Space(nbr) - ''renvoie string de space''
*Trim(string) - ''renvoie string sans espace ni gauche ni droite''
*UCase(string) - ''renvoie string en majuscule''

== de date et d'heure ==
*Date() - ''renvoie date sys''
*DateAdd(interval,nbr,Date) - ''renvoie date + interval''
*DateDiff(interval,date1,date2,[firstdayofweek],[firstdayofyear]) - ''renvoie interval''
*DatePart(interval,Date,[firstdayofweek],[firstdayofyear]) - ''renvoie partie spécifiée''
*DateSerial(Year,Month,Date) - ''renvoie variant de type date''
*DateValue(Date) - ''renvoie variant de type date''
*Day(Date) - ''renvoie jour du mois''
*Hour(Time) - ''renvoie heure''
*Minute(Time) - ''renvoie minute'
*Month(Date) - ''renvoie mois en chiffre''
*MonthName(Month,[abbreviate]) - ''renvoie mois en lettre''
*Now() - ''renvoie date et heure sys''
*Second(Time) - ''renvoie seconde''
*Time() - ''renvoie heure sys''
*Timer() - ''renvoie nbre de sec depuis 00:00''
*TimeSerial(Hour,Minute,Second) - ''renvoit variant de type date''
*TimeValue(Time) - ''renvoit variant de type date''
*Weekday(Date,[fistdayofweek]) - ''renvoie jour semaine en chiffre''
*WeekdayName(Weekday,abbreviate,firstdayofweek) - ''renvoie jour semaine en lettre''
*Year(Date) - ''renvoie annee de date''

== liées aux tableaux ==

*Array(arg) - ''renvoie variant contenant tableau''
*Erase tableau - ''libère tableau''
*Filter(InputStrings,Value,[Include],[compare]) - ''renvoie tableau commençant par 0 contenant sous ensemble de string''
*LBound(arrayname,[dimension]) - ''renvoie plus petit indice tableau''
*Split(expr,[delimiter],[count],[compare]) - ''renvoie tableau commençant par 0 comprenant # de string''
*UBound(arrayname,[dimension]) - ''renvoie plus grand indice tableau''

== autres fonctions ==
*CreateObject(class) - ''renvoie ref à objet automation''
*Eval(string) - ''renvoie resultat''
*Execute ins - ''execute ins''
*ExecuteGlobal ins - ''execute ins globale''
*GetLocale() - ''renvoie valeur ID parametre regionnaux sys''
*GetObject([pathname],[class]) - ''renvoie ref à objet automation de fichier''
*GetRef(string) - ''renvoie ref à procedure''
*InputBox(prompt,[title],[default],[xpos],[ypos],[helpfile],[context]) - ''prompt''
*LoadPicture([stringexpr) - ''renvoie img''
*MsgBox(prompt,[buttons],[title],[helpfile],[context]) - ''msgbox''
*RGB(red,green,blue) - ''renvoie int rgb''
*ScriptEngine() - ''renvoie string de script utilisé''
*ScriptEngineBuildVersion() - ''renvoie N° version''
*ScriptEngineMajorVersion() - ''renvoie N° version principale''
*ScriptEngineMinorVersion() - ''renvoie N° version secondaire''
*SetLocate(Icid) - ''def param regionnaux globaux''
*TypeName(varname) - ''renvoit string d'info sur variant''
*VarType(varname) - ''renvoit valeur sous type de var''

= Objets =


*Err - ''infos relatives aux erreurs d'exec''
**Proprietes
::Description
::Helpcontext
::Helpfile
::Number
::Source
**Methodes
::Clear()
::Raise(nbr,src,desc,hlpf,hlpcontext)


*RegExp - ''gestion des regular expr''
**Proprietes
::Global
::IgnoreCase
::Pattern
**Methodes
::Execute(string)
::Replace(string1,string2)
::Test(string)


*Match - ''accès aux proprietes correspondant de regular expr''
**Proprietes
::FirstIndex
::Length
::Value


*Matches - ''collection de match''
**Proprietes
::Count
::Item(key)


*SubMatches - ''collection de sous-match''
**Proprietes
::Count
::Item(key)

= Constantes =

== Chaînes de caractères ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center bgcolor="#EFEFEF"
| CONSTANTE || VALEUR || DESCRIPTION
|- align=center
| vbCr || chr(13) || Retour chariot
|- align=center bgcolor="#EFEFEF"
| vbCrlf || chr(13)+chr(10) || Retour chariot et saut de ligne
|- align=center
| vbFormFeed || chr(12) || Saut de page
|- align=center bgcolor="#EFEFEF"
| vblf || chr(10) || Saut de ligne
|- align=center
| vbNewline || chr(13)+chr(10) || Nouvelle ligne
|- align=center bgcolor="#EFEFEF"
| vbNullChar || chr(0) || 0
|- align=center
| vbNullString || chaîne ayant val. 0 || chaine nulle
|- align=center bgcolor="#EFEFEF"
| vbTab || chr(9) || tab horizontale
|- align=center
| vbVerticalTab || chr(11) || tab verticale
|}

== Couleur ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbBlack || &h00 || Noir
|- align=center bgcolor="#EFEFEF"
| vbRed || &hFF || Rouge
|- align=center
| vbGreen || &hFF00 || Vert
|- align=center bgcolor="#EFEFEF"
| vbYellow || &hFFFF || Jaune
|- align=center
| vbBlue || &hFF0000 || Bleu
|- align=center bgcolor="#EFEFEF"
| vbMagenta || &hFF00FF || Magenta
|- align=center
| vbCyan || &hFFFF00 || Cyan
|- align=center bgcolor="#EFEFEF"
| vbWhite || &hFFFFFF || Blanc
|}

== Comparaison ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbBinaryCompare || 0 || Comparaison binaire
|- align=center bgcolor="#EFEFEF"
| vbTextCompare || 1 || Comparaison texte
|}

== Date et heure ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbSunday || 1 || Dimanche
|- align=center bgcolor="#EFEFEF"
| vbMonday || 2 || Lundi
|- align=center
| vbTuesday || 3 || Mardi
|- align=center bgcolor="#EFEFEF"
| vbWednesday || 4 || Mercredi
|- align=center
| vbThursday || 5 || Jeudi
|- align=center bgcolor="#EFEFEF"
| vbFriday || 6 || Vendredi
|- align=center
| vbSaturday || 7 || Samedi
|- align=center bgcolor="#EFEFEF"
| vbUseSystem || 0 || Format de date des param regionaux
|- align=center
| vbUseSystemDayOfWeek || 0 || Jour semaine des param regionaux
|- align=center bgcolor="#EFEFEF"
| vbFirstJan1 || 1 || Utilise la semaine du 01 Janvier
|- align=center
| vbFisrtFourDays || 2 || Première semaine avec 4 jours dans nouvelle annee
|- align=center bgcolor="#EFEFEF"
| vbFirstFullWeek || 3 || Utilise la premiere semaine complete de l'annee
|}

== Format de date ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbGeneralDate || 0 || Date et heure
|- align=center bgcolor="#EFEFEF"
| vbLongDate || 1 || Date complète
|- align=center
| vbShortDate || 2 || Date abrégée
|- align=center bgcolor="#EFEFEF"
| vbLongTime || 3 || Heure complète
|- align=center
| vbShortTime || 4 || Heure abrégée
|}

== MsgBox ==


{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbOkOnly || 0 || ok
|- align=center bgcolor="#EFEFEF"
| vbOkCancel || 1 || ok/cancel
|- align=center
| vbAbortRetryIgnore || 2 || abort/retry/ignore
|- align=center bgcolor="#EFEFEF"
| vbYesNoCancel || 3 || yes/no/cancel
|- align=center
| vbYesNo || 4 || yes/no
|- align=center bgcolor="#EFEFEF"
| vbRetryCancel || 5 || retry/cancel
|- align=center
| vbCritical || 16 || message critique
|- align=center bgcolor="#EFEFEF"
| vbQuestion || 32 || demande avertissement
|- align=center
| vbExclamation || 48 || exclamation
|- align=center bgcolor="#EFEFEF"
| vbInformation || 64 || information
|- align=center
| vbDefaultButton1 || 0 || bouton1
|- align=center bgcolor="#EFEFEF"
| vbDefaultButton2 || 256 || bouton2
|- align=center
| vbDefaultButton3 || 542 || bouton3
|- align=center bgcolor="#EFEFEF"
| vbDefaultButton4 || 768 || bouton4
|- align=center
| vbApplicationModal || 0 || boite modale pour l'app
|- align=center bgcolor="#EFEFEF"
| vbSystemModal || 4096 || boite modale pour le sys
|}

== VarType ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbEmpty || 0 || non init (defaut)
|- align=center bgcolor="#EFEFEF"
| vbNull || 1 || pas de data
|- align=center
| vbInteger || 2 || sous-type integer
|- align=center bgcolor="#EFEFEF"
| vbLong || 3 || sous-type long
|- align=center
| vbSingle || 4 || sous-type single
|- align=center bgcolor="#EFEFEF"
| vbDouble || 5 || sous-type double
|- align=center
| vbCurrency || 6 || sous-type currency
|- align=center bgcolor="#EFEFEF"
| vbDate || 7 || sous-type date
|- align=center
| vbString || 8 || sous-type string
|- align=center bgcolor="#EFEFEF"
| vbObject || 9 || objet
|- align=center
| vbError || 10 || sous-type error
|- align=center bgcolor="#EFEFEF"
| vbBoolean || 11 || sous-type booleen
|- align=center
| vbVariant || 12 || variant pour tableau variant
|- align=center bgcolor="#EFEFEF"
| vbDataObject || 13 || objet d'acces aux donnees
|- align=center
| vbDecimal || 14 || sous-type decimal
|- align=center bgcolor="#EFEFEF"
| vbByte || 17 || sous-type byte
|- align=center
| vbArray || 8192 || tableau
|}

== Autre constantes ==
{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center
| vbObjectError || -2147221504 || num d'erreur doivent etre superieur
|- align=center bgcolor="#EFEFEF"
| vbUseDefault || -2 || utiliser valeur par defaut des params
|- align=center
| vbTrue || -1 || true
|- align=center bgcolor="#EFEFEF"
| vbFalse || 0 || false
|}

= Codes d'erreur =
Il y a deux types d'erreurs :
*execution
*syntaxe
== Execution ==
{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center bgcolor="#EFEFEF"
| NUMERO || DESCRIPTION
|- align=center
| 5 || appel de procedure incorrect
|- align=center bgcolor="#EFEFEF"
| 6 || depassement de capacite
|- align=center
| 7 || memoire insuffisante
|- align=center bgcolor="#EFEFEF"
| 9 || indice hors plage
|- align=center
| 10 || tableau fixe ou verrouille
|- align=center bgcolor="#EFEFEF"
| 11 || division par zero
|- align=center
| 13 || type incompatible
|- align=center bgcolor="#EFEFEF"
| 14 || espace de chaine insuffisant
|- align=center
| 17 || operation impossible
|- align=center bgcolor="#EFEFEF"
| 28 || espace pile insuffisant
|- align=center
| 35 || sub non definie
|- align=center bgcolor="#EFEFEF"
| 48 || erreur chargement de dll
|- align=center
| 51 || erreur interne
|- align=center bgcolor="#EFEFEF"
| 91 || var d'objet non definie
|- align=center
| 92 || boucle non init
|- align=center bgcolor="#EFEFEF"
| 94 || utilisation incorrecte de null
|- align=center
| 424 || objet requis
|- align=center bgcolor="#EFEFEF"
| 429 || activex ne peut pas creer l'objet
|- align=center
| 430 || classe ne gere pas automation
|- align=center bgcolor="#EFEFEF"
| 432 || fichier ou classe introuvable
|- align=center
| 438 || methode ou propriete non gere
|- align=center bgcolor="#EFEFEF"
| 445 || objet ne gere pas action
|- align=center
| 447 || objet ne gere pas les param
|- align=center bgcolor="#EFEFEF"
| 448 || arg introuvable
|- align=center
| 449 || arg obligatoire
|- align=center bgcolor="#EFEFEF"
| 450 || nbre arg ou propriete incorrecte
|- align=center
| 451 || objet n'est pas une collection
|- align=center bgcolor="#EFEFEF"
| 458 || type automation non gere
|- align=center
| 462 || machine distante indisponnible
|- align=center bgcolor="#EFEFEF"
| 481 || image incorrecte
|- align=center
| 500 || variable indefinie
|- align=center bgcolor="#EFEFEF"
| 502 || objet non securise pour script
|- align=center
| 503 || objet non securise pour init
|- align=center bgcolor="#EFEFEF"
| 504 || objet non securise pour creation
|- align=center
| 505 || reference incorrecte ou non qualifiee
|- align=center bgcolor="#EFEFEF"
| 506 || classe non definie
|- align=center
| 507 || exception
|- align=center bgcolor="#EFEFEF"
| 5008 || affectation illegale
|- align=center
| 5017 || Erreur syntaxique dans ER
|- align=center bgcolor="#EFEFEF"
| 5018 || quantifiant innatendu
|- align=center
| 5019 || ']' attendu dans ER
|- align=center bgcolor="#EFEFEF"
| 5020 || ')' attendu dans ER
|- align=center
| 5021 || jeu de char incorrect
|}

== Syntaxe ==

{| border="0" style="border: 0px solid #999; background-color:#FFFFFF"
|- align=center bgcolor="#EFEFEF"
| NUMERO || DESCRIPTION
|- align=center
| 1052 || trop de methodes et proprietes
|- align=center bgcolor="#EFEFEF"
| 1044 || parentheses interdites
|- align=center
| 1053 || classe sans arg
|- align=center bgcolor="#EFEFEF"
| 1058 || 'default' que dans get
|- align=center
| 1057 || 'default' + 'public'
|- align=center bgcolor="#EFEFEF"
| 1005 || '(' attendu
|- align=center
| 1006 || ')' attendu
|- align=center bgcolor="#EFEFEF"
| 1011 || '=' attendu
|- align=center
| 1021 || 'case' attendu
|- align=center bgcolor="#EFEFEF"
| 1047 || 'class' attendu
|- align=center
| 1025 || fin ins attendu
|- align=center bgcolor="#EFEFEF"
| 1014 || 'end' attendu
|- align=center
| 1023 || expr attendu
|- align=center bgcolor="#EFEFEF"
| 1015 || 'function' attendu
|- align=center
| 1010 || identificateur attendu
|- align=center bgcolor="#EFEFEF"
| 1012 || 'lf' attendu
|- align=center
| 1046 || 'ln' attendu
|- align=center bgcolor="#EFEFEF"
| 1026 || constante (int) attendu
|- align=center
| 1049 || let, get, set attendu
|- align=center bgcolor="#EFEFEF"
| 1045 || constante (string) attendu
|- align=center
| 1019 || 'loop' attendu
|- align=center bgcolor="#EFEFEF"
| 1020 || 'next' attendu
|- align=center
| 1050 || 'property' attendu
|- align=center bgcolor="#EFEFEF"
| 1022 || 'select' attendu
|- align=center
| 1024 || ins attendu
|- align=center bgcolor="#EFEFEF"
| 1016 || 'sub' attendu
|- align=center
| 1017 || 'then' attendu
|- align=center bgcolor="#EFEFEF"
| 1013 || 'to' attendu
|- align=center
| 1018 || 'wend' attendu
|- align=center bgcolor="#EFEFEF"
| 1027 || 'while' 'until' attendu
|- align=center
| 1028 || 'while' 'until' ou fin ins attendu
|- align=center bgcolor="#EFEFEF"
| 1029 || 'with' attendu
|- align=center
| 1030 || identificateur trop long
|- align=center bgcolor="#EFEFEF"
| 1014 || char incorrect
|- align=center
| 1039 || 'exit' incorrect
|- align=center bgcolor="#EFEFEF"
| 1040 || variable de ctrl de 'for' incorrecte
|- align=center
| 1013 || nbre incorrect
|- align=center bgcolor="#EFEFEF"
| 1037 || utilisation incorrecte de 'me'
|- align=center
| 1038 || 'loop' sans 'do'
|- align=center bgcolor="#EFEFEF"
| 1048 || doit etre defini dans classe
|- align=center
| 1042 || doit premiere ins de ligne
|- align=center bgcolor="#EFEFEF"
| 1041 || nom redefini
|- align=center
| 1051 || nombre arg inegal
|- align=center bgcolor="#EFEFEF"
| 1001 || memoire insuffisante
|- align=center
| 1054 || arg manquant dans let ou set
|- align=center bgcolor="#EFEFEF"
| 1002 || erreur sythaxe
|- align=center
| 1055 || next attendu
|- align=center bgcolor="#EFEFEF"
| 1015 || constante de chaine non terminee
|}

= LIENS INTERNES =
Initiation au VBScript par l'exemple
* [[Application VBS]]
* [[Programmation PowerShell]]

= LIENS EXTERNES =
* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp
* http://www.commentcamarche.net/vbscript/vbsintro.php3
* http://www.vbfrance.com/
* http://www.lehtml.com/vb/

{{Programmation}}

[[Catégorie:Langages de programmation]]

[[en:Visual Basic]]

Version du 8 juin 2012 à 19:21

VBScript ou VBS (Visual Basic Script) est un langage parsé par les interpréteurs supportant le WSH de microsoft.

  • Sur client : < script langage="VBScript" />
  • Sur serveur : <% script langage="VBScript" %>


Opérateurs

+ addition
- soustraction
* multiplication
^ puissance
/ division à float
\ division entière
mod modulo - reste de la division entière
< plus petit
<= plus petit ou égal
> plus grand
>= plus grand ou égal
<> différent
not non logique
and et logique
or ou logique
xor xor logique
eqv equivalence
imp implication
& concaténation

Déclarations

Contrairement à beaucoup d'autres langages, le vbs n'est pas sensible à la casse.

  • LÉGENDE
src - source
nm - nom
var - variable
expr - expression
ins - instruction
arg - argument
cond - condition

  • Déclaration
option explicit - force déclaration de toutes variables dans scr
dim nm(src) - variable
redim [preserve] var(src)
const nm=expr - constante
  • Procédure - execute instructions
sub nm(arg1,arg2,...)
[ins]
[exit sub]
[ins]
end sub
  • Fonction - retourne une valeur en sortie à nm
function nm(arg1,arg2,...)
[ins]
[nm=expr]
[exit function]
[ins]
[nm=expr]
end function
  • Get - comme fonction simple
property get nm(arg1,arg2,...) as [type]
...
[ins]
[nm=expr]
end property
  • Let - comme fonction simple
property let nm(arg1,arg2,...)
...
[ins]
end property
  • Set - comme fonction simple
property set nm(arg1,arg2,...)
...
[ins]
end property
  • Classe - retourne initialize || terminate
class ClassName
[var]
Private Sub Class_Initialize()
[ins]
End Sub
Private Sub Class_Terminate()
[ins]
End Sub
Public Function NomMethode([arg])
[ins]
End Function
end Class

nota : const/sub/function/property sont déclarables en [public [default] | private]

ex 1
public function nm(args) - pour toute la src
ex 2
sub nm(args)
private const=expr - n'est déclarée et n'est valable que dans la procédure
end sub

Instructions de contrôle

  • TEST
If cond Then [ins] Else [ins]
If cond1 Then
 [ins]
Elseif cond2 Then
 [ins]
Else
 [ins]
Endif
Select Case expression
 Case expr1
  [ins]
 Case expr2
  [ins]
 Case Else
  [ins]
End Select
  • BOUCLE
For cpt = début To fin [Step pas]
 [ins]
 [Exit For]
 [ins]
Next [cpt]
For Each élément In groupe
 [ins]
 [Exit For]
 [ins]
Next élément
Do [{While | Until} condition]
 [ins]
 [Exit Do]
 [ins]
Loop
Do
 [ins]
 [Exit Do]
 [ins]
Loop [{While | Until} condition]
While condition
 [ins]
Wend
  • APPELS
With obj
 [ins]
End Width
Call nom [args]
  • ERREURS
On Error Resume Next
On Error Goto 0
  • REMARQUES
Rem
  • AFFECTATION DE REFERENCES
Set objvar=[obj expr | New classname | Nothing ]
  • ASSOCIATION DE REFERENCE
Set object.eventname=GetRef(procname)

Fonctions

conversion et mise en forme

  • CBool(expr) - conversion en variant booleen
  • CByte(expr) - conversion en variant byte
  • CCur(expr) - conversion en variant currency
  • CDate(expr) - conversion en variant date
  • CDbl(expr) - conversion en variant double
  • CInt(expr) - conversion en variant integer
  • CLng(expr) - conversion en variant long
  • CSng(expr) - conversion en variant single
  • CStr(expr) - conversion en variant string
  • FormatCurrency(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - conversion formatée en variant currency
  • FormatDateTime(date,[NamedFormat]) - conversion formatée en variant date
  • FormatNumber(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - conversion formatée en variant nombre
  • FormatPercent(expr,[NumDigitsAfterDecimal],[IncludeLeadingDigit],[UseParensForNegativeNumber],[GroupDigits]) - conversion formatée en variant percent
  • Hex(nbr) - conversion en variant hexadecimal
  • IsArray(expr) - renvoit booleen si tableau
  • IsDate(expr) - renvoit booleen si date
  • IsEmpty(expr) - renvoit booleen si vide
  • IsNull(expr) - renvoit booleen si null
  • IsNumeric(expr) - renvoit booleen si nbr
  • IsObject(identifier) - renvoit booleen si obj automation
  • Oct(nbr) - conversion en string octal

mathématiques

  • Abs(nbr) - renvoie valeur absolue
  • Atn(nbr) - renvoie arc tangent
  • Cos(nbr) - renvoie cosinus
  • Exp(nbr) - renvoie la puissance
  • Int(nbr) - renvoie partie entière
  • Fix(nbr) - renvoie partie entière
  • Log(nbr) - renvoie log népérien
  • Sqr(nbr) - renvoie racine carrée
  • Tan(nbr) - renvoie tangente
  • Sgn(nbr) - renvoie signe
  • Randomize(nbr) - init nbr aleatoire !!les nombres ne sont pas aleatoire en vbs!!
  • Rnd(nbr) - renvoie nbr aleatoire
  • Round(expr,[numdecimalplaces]) - renvoie l'arrondi
  • Sin(nbr) - renvoie sinus

de traitement de chaînes

  • Asc(string) - renvoie code ansi du 1er char
  • Chr(charcode) - renvoie le char du code ansi
  • inStr(start,string,string2,[compare]) - renvoie 1ère position d'un string dans un autre
  • InStrRev(delimiter) - renvoie position d'un string dans un autre en partant de fin
  • Join(string) - renvoie string joins partant d'un tableau
  • LCase(string) - conversion en minuscule
  • Left(string,length) - renvoie sous string partant de gauche
  • Len(string) - renvoie nbr de char dans string
  • LTrim(string) - renvoie string sans espace à gauche
  • Mid(string,start,[length]) - renvoie sous string partant de milieu
  • Replace(expr,find,replacement,[start],[count],[compare]) - remplace string dans string
  • Right(string,length) - renvoie sous string partant de droite
  • RTrim(string) - renvoie string sans espace à droite
  • StrComp(string1,string2,[compare]) - renvoie valeur de comparaison de string
  • String([nbr],[char]) - renvoie string de char repete
  • StrReverse(string) - renvoie string inverse
  • Space(nbr) - renvoie string de space
  • Trim(string) - renvoie string sans espace ni gauche ni droite
  • UCase(string) - renvoie string en majuscule

de date et d'heure

  • Date() - renvoie date sys
  • DateAdd(interval,nbr,Date) - renvoie date + interval
  • DateDiff(interval,date1,date2,[firstdayofweek],[firstdayofyear]) - renvoie interval
  • DatePart(interval,Date,[firstdayofweek],[firstdayofyear]) - renvoie partie spécifiée
  • DateSerial(Year,Month,Date) - renvoie variant de type date
  • DateValue(Date) - renvoie variant de type date
  • Day(Date) - renvoie jour du mois
  • Hour(Time) - renvoie heure
  • Minute(Time) - renvoie minute'
  • Month(Date) - renvoie mois en chiffre
  • MonthName(Month,[abbreviate]) - renvoie mois en lettre
  • Now() - renvoie date et heure sys
  • Second(Time) - renvoie seconde
  • Time() - renvoie heure sys
  • Timer() - renvoie nbre de sec depuis 00:00
  • TimeSerial(Hour,Minute,Second) - renvoit variant de type date
  • TimeValue(Time) - renvoit variant de type date
  • Weekday(Date,[fistdayofweek]) - renvoie jour semaine en chiffre
  • WeekdayName(Weekday,abbreviate,firstdayofweek) - renvoie jour semaine en lettre
  • Year(Date) - renvoie annee de date

liées aux tableaux

  • Array(arg) - renvoie variant contenant tableau
  • Erase tableau - libère tableau
  • Filter(InputStrings,Value,[Include],[compare]) - renvoie tableau commençant par 0 contenant sous ensemble de string
  • LBound(arrayname,[dimension]) - renvoie plus petit indice tableau
  • Split(expr,[delimiter],[count],[compare]) - renvoie tableau commençant par 0 comprenant # de string
  • UBound(arrayname,[dimension]) - renvoie plus grand indice tableau

autres fonctions

  • CreateObject(class) - renvoie ref à objet automation
  • Eval(string) - renvoie resultat
  • Execute ins - execute ins
  • ExecuteGlobal ins - execute ins globale
  • GetLocale() - renvoie valeur ID parametre regionnaux sys
  • GetObject([pathname],[class]) - renvoie ref à objet automation de fichier
  • GetRef(string) - renvoie ref à procedure
  • InputBox(prompt,[title],[default],[xpos],[ypos],[helpfile],[context]) - prompt
  • LoadPicture([stringexpr) - renvoie img
  • MsgBox(prompt,[buttons],[title],[helpfile],[context]) - msgbox
  • RGB(red,green,blue) - renvoie int rgb
  • ScriptEngine() - renvoie string de script utilisé
  • ScriptEngineBuildVersion() - renvoie N° version
  • ScriptEngineMajorVersion() - renvoie N° version principale
  • ScriptEngineMinorVersion() - renvoie N° version secondaire
  • SetLocate(Icid) - def param regionnaux globaux
  • TypeName(varname) - renvoit string d'info sur variant
  • VarType(varname) - renvoit valeur sous type de var

Objets

  • Err - infos relatives aux erreurs d'exec
    • Proprietes
Description
Helpcontext
Helpfile
Number
Source
    • Methodes
Clear()
Raise(nbr,src,desc,hlpf,hlpcontext)


  • RegExp - gestion des regular expr
    • Proprietes
Global
IgnoreCase
Pattern
    • Methodes
Execute(string)
Replace(string1,string2)
Test(string)


  • Match - accès aux proprietes correspondant de regular expr
    • Proprietes
FirstIndex
Length
Value


  • Matches - collection de match
    • Proprietes
Count
Item(key)


  • SubMatches - collection de sous-match
    • Proprietes
Count
Item(key)

Constantes

Chaînes de caractères

CONSTANTE VALEUR DESCRIPTION
vbCr chr(13) Retour chariot
vbCrlf chr(13)+chr(10) Retour chariot et saut de ligne
vbFormFeed chr(12) Saut de page
vblf chr(10) Saut de ligne
vbNewline chr(13)+chr(10) Nouvelle ligne
vbNullChar chr(0) 0
vbNullString chaîne ayant val. 0 chaine nulle
vbTab chr(9) tab horizontale
vbVerticalTab chr(11) tab verticale

Couleur

vbBlack &h00 Noir
vbRed &hFF Rouge
vbGreen &hFF00 Vert
vbYellow &hFFFF Jaune
vbBlue &hFF0000 Bleu
vbMagenta &hFF00FF Magenta
vbCyan &hFFFF00 Cyan
vbWhite &hFFFFFF Blanc

Comparaison

vbBinaryCompare 0 Comparaison binaire
vbTextCompare 1 Comparaison texte

Date et heure

vbSunday 1 Dimanche
vbMonday 2 Lundi
vbTuesday 3 Mardi
vbWednesday 4 Mercredi
vbThursday 5 Jeudi
vbFriday 6 Vendredi
vbSaturday 7 Samedi
vbUseSystem 0 Format de date des param regionaux
vbUseSystemDayOfWeek 0 Jour semaine des param regionaux
vbFirstJan1 1 Utilise la semaine du 01 Janvier
vbFisrtFourDays 2 Première semaine avec 4 jours dans nouvelle annee
vbFirstFullWeek 3 Utilise la premiere semaine complete de l'annee

Format de date

vbGeneralDate 0 Date et heure
vbLongDate 1 Date complète
vbShortDate 2 Date abrégée
vbLongTime 3 Heure complète
vbShortTime 4 Heure abrégée

MsgBox

vbOkOnly 0 ok
vbOkCancel 1 ok/cancel
vbAbortRetryIgnore 2 abort/retry/ignore
vbYesNoCancel 3 yes/no/cancel
vbYesNo 4 yes/no
vbRetryCancel 5 retry/cancel
vbCritical 16 message critique
vbQuestion 32 demande avertissement
vbExclamation 48 exclamation
vbInformation 64 information
vbDefaultButton1 0 bouton1
vbDefaultButton2 256 bouton2
vbDefaultButton3 542 bouton3
vbDefaultButton4 768 bouton4
vbApplicationModal 0 boite modale pour l'app
vbSystemModal 4096 boite modale pour le sys

VarType

vbEmpty 0 non init (defaut)
vbNull 1 pas de data
vbInteger 2 sous-type integer
vbLong 3 sous-type long
vbSingle 4 sous-type single
vbDouble 5 sous-type double
vbCurrency 6 sous-type currency
vbDate 7 sous-type date
vbString 8 sous-type string
vbObject 9 objet
vbError 10 sous-type error
vbBoolean 11 sous-type booleen
vbVariant 12 variant pour tableau variant
vbDataObject 13 objet d'acces aux donnees
vbDecimal 14 sous-type decimal
vbByte 17 sous-type byte
vbArray 8192 tableau

Autre constantes

vbObjectError -2147221504 num d'erreur doivent etre superieur
vbUseDefault -2 utiliser valeur par defaut des params
vbTrue -1 true
vbFalse 0 false

Codes d'erreur

Il y a deux types d'erreurs :

  • execution
  • syntaxe

Execution

NUMERO DESCRIPTION
5 appel de procedure incorrect
6 depassement de capacite
7 memoire insuffisante
9 indice hors plage
10 tableau fixe ou verrouille
11 division par zero
13 type incompatible
14 espace de chaine insuffisant
17 operation impossible
28 espace pile insuffisant
35 sub non definie
48 erreur chargement de dll
51 erreur interne
91 var d'objet non definie
92 boucle non init
94 utilisation incorrecte de null
424 objet requis
429 activex ne peut pas creer l'objet
430 classe ne gere pas automation
432 fichier ou classe introuvable
438 methode ou propriete non gere
445 objet ne gere pas action
447 objet ne gere pas les param
448 arg introuvable
449 arg obligatoire
450 nbre arg ou propriete incorrecte
451 objet n'est pas une collection
458 type automation non gere
462 machine distante indisponnible
481 image incorrecte
500 variable indefinie
502 objet non securise pour script
503 objet non securise pour init
504 objet non securise pour creation
505 reference incorrecte ou non qualifiee
506 classe non definie
507 exception
5008 affectation illegale
5017 Erreur syntaxique dans ER
5018 quantifiant innatendu
5019 ']' attendu dans ER
5020 ')' attendu dans ER
5021 jeu de char incorrect

Syntaxe

NUMERO DESCRIPTION
1052 trop de methodes et proprietes
1044 parentheses interdites
1053 classe sans arg
1058 'default' que dans get
1057 'default' + 'public'
1005 '(' attendu
1006 ')' attendu
1011 '=' attendu
1021 'case' attendu
1047 'class' attendu
1025 fin ins attendu
1014 'end' attendu
1023 expr attendu
1015 'function' attendu
1010 identificateur attendu
1012 'lf' attendu
1046 'ln' attendu
1026 constante (int) attendu
1049 let, get, set attendu
1045 constante (string) attendu
1019 'loop' attendu
1020 'next' attendu
1050 'property' attendu
1022 'select' attendu
1024 ins attendu
1016 'sub' attendu
1017 'then' attendu
1013 'to' attendu
1018 'wend' attendu
1027 'while' 'until' attendu
1028 'while' 'until' ou fin ins attendu
1029 'with' attendu
1030 identificateur trop long
1014 char incorrect
1039 'exit' incorrect
1040 variable de ctrl de 'for' incorrecte
1013 nbre incorrect
1037 utilisation incorrecte de 'me'
1038 'loop' sans 'do'
1048 doit etre defini dans classe
1042 doit premiere ins de ligne
1041 nom redefini
1051 nombre arg inegal
1001 memoire insuffisante
1054 arg manquant dans let ou set
1002 erreur sythaxe
1055 next attendu
1015 constante de chaine non terminee

LIENS INTERNES

Initiation au VBScript par l'exemple

LIENS EXTERNES


Cette page fait partie du livre Programmation