Bonjour Cathy !
Le type porte uniquement sur les valeurs retournées par ton tableau.
exemple
Dim t(3,5) As long renvoie un entier long
Long integer variables can store any whole number between –2147483648 and 2147483647. A long integer variable can takes up to four bytes of memory. The type declaration symbol for a long integer is &. Calculations with long integer variables are very fast and are particularly useful for loop counters. If you assign a floating point number to a long integer variable, the number is rounded up or down to the next whole number.
Voici 3 exemples, bon courage !
Code : Tout sélectionner
Sub EssaiTableauBiDimensionnel()
Dim t(3,5) As String ' tableau bi-dimensionnel
t(2,4) = "Bonjour"
print t(2,4)
End Sub
' Ne pas confondre un tableau multidimensionnel et un tableau de tableaux.
' Pierre-Yves Samyn
'La double indexation pour un tableau de tableaux n'est pas acceptée par OOoBasic avant la version 3.0.
'C'est une nouveauté de la 3.0 que je ne connaissais pas :super:
Sub TableauxDeTableaux
Dim tValeur(3) as variant, i as integer
tValeur(1) = array ("a","b","c")
tValeur(2) = array ("d","e","f")
tValeur(3) = array ("g","h","i")
for i = lbound(tValeur(2)) to ubound(tValeur(2))
print tValeur(2)(i)
next i
print tValeur(2)(0)
End Sub
' #FUNCTION# ====================================================================================================================
' Name...........: Tab2D()
' Description ...: 'Tableau 2 dimensions (Array)
' Parameters ....: Tab2D()
' Syntax ........: FormaterEnTypeTexte()
' $vValue - Value to add
' Return values .: Success - void
' Failure - -1, sets @error
' |1 - $avArray is not an array
' |2 - $avArray is not a 1 dimensional array
' Author ........: Jacques BOISGONTIER
' Modified.......: martinbrait - code cleanup
' Remarks .......: prérequis, une feuille de classeur. Utiliser le bon type lors de l'écriture dans la cellule de classeur !
' Related .......:
' Link ..........;
' Example .......' Yes,
'On obtient
'11 12
'21 22
'31 32
' ====================================================
Sub Tab2D()
Dim lig,col As Integer
Dim oCell
Dim b As Variant
Dim s As String
Dim i As integer
Dim oDoc As Object
oDoc = createNewCalcDoc()
Dim a(1 To 3, 1 To 2)As Integer ' 3 lignes x 2 colonnes, stockant des valeurs de type integer
a(1, 1) = 11
a(1, 2) = 12
a(2, 1) = 21
a(2, 2) = 22
a(3, 1) = 31
a(3, 2) = 32
For lig = LBound(a, 1) To UBound(a, 1)
For col = LBound(a, 2) To UBound(a, 2)
oCell = oDoc.Sheets(0).getCellByPosition(lig, col)
oCell.setValue(a(lig, col)) 'attention à bien typer, en fonction du type de donnée à transférer
Next col
Next lig
End Sub