'---chaine de caractères-------------------------------------- 'Les outils de conversions et de traitement des chaines 'Par ordre alphabétique et repris dans le dictionnaire. ' pour controler une instructions, supprimer le REM(') avant le WAIT 'et lancer le simulateur. ce programme n'utilise pas la carte de 'programmation. '...format...fusing...INSTR..Lcase...LEN...Ucase...LEFT...RIGHT...MID 'LTRIM...RTRIM...TRIM...SPACE...SPC...STR...STRING ' 'Jp Duval Le 13 -11 -2002 '------------------------------------------------------------- Dim Mot As String * 20 Dim Secondmot As String * 20 Dim Nombre As Integer Dim Nombresingle As Single '----FORMAT--------------------------------------------------- 'formatage d'une variable string numérique Nombre = 1234 Mot = "1234" Mot = Format(mot , "+") Print "mot: " ; Mot Mot = Format(mot , " 00.00") Print "mot: " ; Mot 'Wait 1 '----FUSING--------------------------------------------------- 'formatage d'une valeur SINGLE avec # Nombresingle = 123.45678 'conversion du nombre en chaine Mot = Str(nombresingle) Print "mot entier: " ; Mot 'print 123.456779477 Mot = Fusing(nombresingle , "#.##") Print "mot arrondi: " ; Mot Mot = Fusing(nombresingle , "#.####") Print "mot arrondi: " ; Mot ' Wait 1 '---INSTR------------------------------------------------------ 'initialise la phrase 1 Mot = "abcdeabcd" 'initialise la phrase à trouver Secondmot = "ab" 'returne la 1° position dans mot Nombre = Instr(mot , Secondmot) Print Nombre 'Wait 1 'Maintenat recherche d'une autre localisation (ab se trouve 2 fois) Nombre = Instr(2 , Mot , Secondmot) Print Nombre 'Wait 1 'doit returner 6 Nombre = Instr(mot , "xx") 'xx n'est pas dans "mot" donc : retourne 0 Print Nombre Wait 1 '---LCASE---UCASE---------------------------------------------- Mot = "coucou" Mot = Ucase(mot) : Print Mot Mot = Lcase(mot) : Print Mot 'Wait 1 '---LEFT--RIGHT-MID-------------------------------------------- Mot = "bonjour ou coucou" Secondmot = Left(mot , 7) Print Secondmot; Secondmot = Right(mot , 6) Print Secondmot 'Waitms 300 For Nombre = 1 To 17 Mot = "bonjour ou coucou" Secondmot = Mid(mot , Nombre , 1) Print Secondmot; 'Waitms 50 Next Nombre 'Wait 1 Print "" '---LEN-------------------------------------------------------- Mot = "bonjour ou coucou" Nombre = Len(mot) Print "longueur de mot: " ; Nombre 'Wait 1 '---LTRIM---RTRIM---TRIM---------------------------------------- Mot = " bonjour " Print "Ltrim" ; Ltrim(mot); Print "fin" Print "Rtrim" ; Rtrim(mot); Print "fin" Print "trim" ; Trim(mot); Print "fin" 'Wait 1 '---SPACE--SPC--------------------------------------------------- Nombre = 15 Mot = Space(nombre) 'assigne à "mot" la valeur de 15 espaces Print Mot ; "fin" Print Spc(nombre) ; "Fin" ' ne fait qu'afficher des espaces, 'peut être utilisé dans une commande LCD, ne consomme pas d'espace mémoire. 'Wait 1 '--STR----------------------------------------------------------- Nombre = 15527 'jouons un peu avec les nombres Mot = Str(nombre) Mot = Mot + " coucou" 'mélangeons numérique et caractères Print Mot 'Wait 1 '---STRING------------------------------------------------------ Mot = String(15 , 64) Print Mot Wait 1 End