Array in Net

Per non perder l'abitudine ad usare il mio blog come bloG-notes memorizzo questa funzione che mi è servita per fare la copia di un intero archivio..(in attesa che imparo le mostruose funzionalità offerte da XML in Net).

'array bidimensionale , che ha come prima dimensione il numero di righe del dataset
Dim __MyArray as Array Array.CreateInstance(GetType(Integer), MyDataSet.Tables("Data").Rows.Count, 1)
'per scorrere l'insieme posso usare il metodo For Each (Integer) in __Myarray oppure
   
Public Function RetrieveNewId(ByVal IdOld As IntegerByVal IdArray(,) As IntegerAs Integer
        
'Questa funzione estrae il valore della seconda dimensione dell'array
        'In Input passo il valore della prima dimensione da cercare.
        'presuppongo che inserisco nel primo livello solo la IdOld e nel secondo livello la newid
        'es. 
        'myarray(0, 0) = 2048 (old)
        'myarray(0, 1) = 334  (new)
        'myarray(1, 0) = 2356 (old) 
        'myarray(1, 1) = 230  (new) 
        'MsgBox(RetrieveNewId(2048, myarray))

        
Dim MyVCounterPrimoLivello, MyVCounterSecondoLivello As Integer
        Dim 
As Integer = IdArray.GetLowerBound(0), j As Integer = IdArray.GetLength(1)
        
For MyVCounterPrimoLivello = IdArray.GetLowerBound(0) To IdArray.GetUpperBound(0)
            
For MyVCounterSecondoLivello = IdArray.GetLowerBound(1) To IdArray.GetUpperBound(1)
                
If IdArray.GetValue(MyVCounterPrimoLivello, MyVCounterSecondoLivello) = IdOld Then
                    
'se lo trovo prendo il secondo livello
                    
Return IdArray.GetValue(MyVCounterPrimoLivello, MyVCounterSecondoLivello + 1)
                
End If
            Next
        Next
    End Function

Spero non vi mettiate a ridere, ma pian piano cerco di affinare le tecniche anche grazie ai preziosi consigli

dei bloggers di UgiDotnet.

P.S. Non me ne vogliano gli altri ma i  miei preferiti sono Andrea Lorenzo.

powered by IMHO 1.2

posted @ venerdì 11 marzo 2005 18:40

Print
«settembre»
domlunmarmergiovensab
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345