pro16
PASCAL VISUAL _VBA EXCEL sintassi per variabili stringa
PASCAL ASSEGNAZIONE valore x:=valore
DICHIARAZIONE con Var nome:tipo;
program pro5a; uses crt; var x:integer ; a,b,c,d:string ; s1,s2,unire:string; begin clrscr; s1:='maria'; s2:='rosa'; a:='laudare'; (* lunghezza stringa *) x:=length(a); writeln(x); (* copia caratteri da inizio a lunghezza-3....radice*) b:=copy(a,1,x-3); writeln(b); (*copia tutta la stringa meno ultimo carattere*) c:=copy(a,1,x-1); writeln(c); (*copia n caratteri da punto indicato...desinenza *) d:=copy(a,x-2,3); writeln(d); (* copia unione stringhe *) writeln(s1+s2); unire:=concat(s1,s2); writeln(unire); readln; end.
ritorna
VBA con EXCEL
right$(testo,n).......n caratteri da destra left$(testo,n)........n caratteri da sinistra len(testo)............lunghezza testo mid$(testo,p,n).......n caratteri da p testo1 & testo2.......unione testi testo1+testo2.........unione testi "testo1"+"testo2".....unione testi "testo1"&"testo2".....unione testi Private Sub CommandButton1_Click() Dim a, b, c As String Dim x As Integer b = "maria" c = "rosa" a = "laudare" Cells(1, 1) = Len(a) x = Len(a) Cells(2, 1) = Right$(a, x - 3) Cells(3, 1) = Left$(a, x - 1) Cells(4, 1) = Mid$(a, 2, 2) Cells(5, 1) = "maria" + "rosa" Cells(6, 1) = b + c Cells(7, 1) = b & c End Sub ritorna
VISUAL BASIC Private Sub CommandButton1_Click() Dim a, b, c As String Dim x As Integer b = "maria" c = "rosa" a = "laudare" Label1.Caption = Len(a) x = Len(a) Label2.Caption = Right$(a, x - 3) Label3.Caption = Left$(a, x - 1) Label4.Caption = Mid$(a, 2, 2) Label5.Caption = "maria" + "rosa" Label6.Caption = b + c Label7.Caption = b & c End Sub
ritorna
EXCEL
=SINISTRA("laudare";3) =LUNGHEZZA("laudare") =CONCATENA("maria";"rosa") =STRINGA.ESTRAI("laudare";3;2) =DESTRA("laudare";3)
ritorna