Visualizzazione dei risultati da 1 a 2 su 2

Discussione: problema array

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2007
    Messaggi
    1,171

    problema array

    buongiorno
    devo in una pagina asp usare un array biirezionale ma non so sapendo la dimensione, l'incremento di un elemento per volta.
    ho fatto cosi:
    prima creo l'array
    dim elenco(1)
    redim preserve elenco(1,7) - qui non ho errore

    poi all'interno di un ciclo devo incrementare l'array di uno mantenendo i dati scritti.

    i=i+1
    redim preserve elenco(i,7)
    ma qua mi da questo errore 'Previsto identificatore'

    perché????

  2. #2
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    590
    dal manuale Microsoft
    ReDim Statement

    Declares dynamic-array variables, and allocates or reallocates storage space at procedure level.
    ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .
    Arguments

    Preserve
    Preserves the data in an existing array when you change the size of the last dimension.
    varname
    Name of the variable; follows standard variable naming conventions.
    subscripts
    Dimensions of an array variable; up to 60 multiple dimensions may be declared. The subscripts argument uses the following syntax:
    upper [,upper] . . .
    The lower bound of an array is always zero.
    Remarks

    The ReDim statement is used to size or resize a dynamic array that has already been formally declared using a Private, Public, or Dim statement with empty parentheses (without dimension subscripts). You can use the ReDim statement repeatedly to change the number of elements and dimensions in an array.
    If you use the Preserve keyword, you can resize only the last array dimension, and you can't change the number of dimensions at all. For example, if your array has only one dimension, you can resize that dimension because it is the last and only dimension. However, if your array has two or more dimensions, you can change the size of only the last dimension and still preserve the contents of the array.
    The following example shows how you can increase the size of the last dimension of a dynamic array without erasing any existing data contained in the array.
    ReDim X(10, 10, 10)
    . . .
    ReDim Preserve X(10, 10, 15) Caution If you make an array smaller than it was originally, data in the eliminated elements is lost.
    When variables are initialized, a numeric variable is initialized to 0 and a string variable is initialized to a zero-length string (""). A variable that refers to an object must be assigned an existing object using the Set statement before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing.
    .... ****
    il numero delle dimensioni è errato...
    Se il vettore è monodimensionale è una cosa, se è una matrice bidimensionale è un'altra cosa...
    Presumo io naturalmente dato che il vettore iniziale è a una dimensione e poi diventa a due dimensioni
    ciao
    Vic53

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.