» »

vba array

vba array

korenje3 ::

A kdo ve kako nastavit prazen multidimenzionalen array?
array(-1,-1)

To pomeni rad bi da ubound vrne -1.
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

prtenjam ::

Pozdravljeni,

Moram priznati, da ne razumem, kaj točno želite, vendar nekako takole? UBound vrne -1 kot želite. Polje ime velikost ene celice. Ne razumem pša kaj bi s poljem oz. tabelo brez celic??

Sub test()
  Dim polje(-1 To -1, -1 To -1) As Double
  
  Debug.Print UBound(polje, 1)
End Sub
Matjaž Prtenjak
https://mnet.si

korenje3 ::

To da namesto napake vrne vrednost -1.
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

imagodei ::

Dim Tabela() as Variant

ne prime?
- Hoc est qui sumus -

korenje3 ::

2D array.
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

imagodei ::

Ne vem kaj točno delaš, prazen dinamični array se kasneje da redimenzionirat tudi v 2D array. Ne vem, če sploh gre tako kot ti hočeš. Pomagalo bi, če bi povedal, kaj točno želiš narediti oz. zakaj rabiš testirat velikost.
- Hoc est qui sumus -

Zgodovina sprememb…

  • spremenil: imagodei ()

imagodei ::

Če rabiš testirat, ali je array sploh alociran, lahko uporabiš kodo iz te strani:
Dim Arr() As Long
Dim N As Long
On Error Resume Next
Err.Clear
N = LBound(Arr)
If Err.Number = 0 Then 
    Debug.Print "Array is allocated."
Else
    Debug.Print "Array is not allocated."
End If


Skratka, neka primitivna Try Catch zanka, če ni alociran imaš error in storiš eno, sicer drugo.

LBound in UBound znata gledat tudi po več dimenzijah (Če ima Arr 2 dimenziji, pač kličeš LBound(Arr, 1) oz LBound(Arr, 2) da dobiš podatek za eno ali drugo dimenzijo).
- Hoc est qui sumus -

Zgodovina sprememb…

  • spremenil: imagodei ()

korenje3 ::

Ok v bistvu sem uporabil kar recordset..

    If RecordSet.EOF = True Then
        rowi = -1
        fr = 1
    Else
        rsrows = RecordSet.GetRows
        rowi = UBound(rsrows, 2)
    End If
    Set FieldsRange = ASheet.Range(TargetRange, TargetRange.cells(1, coli + UBound(EmptyColumns) + 2))
    Set TotalRange = ASheet.Range(TargetRange, TargetRange.cells(rowi + 2, coli + UBound(EmptyColumns) + 2))
    Set TotalDataRange = ASheet.Range(TargetRange.cells(2, 1), TargetRange.Offset(1).cells(rowi + 1 + fr, coli + UBound(EmptyColumns) + 2))
    ' UBound(rsrows, 1) = columns
    ' UBound(rsrows, 2) = rows
    If GenerateTable = True And ObjectExists(TableName) = True And Update = True And KeyColumn = "" Then
        If ShiftRows = True Then
            With ASheet.ListObjects(TableName)
                If .ListRows.Count < rowi + 1 Then
                    If .ListRows.Count = 0 Then .ListRows.Add: waszero = True
                    If rowi > 0 Then .DataBodyRange.Rows(.ListRows.Count + 1 & ":" & rowi + 1).Insert Shift:=xlDown
                ElseIf .ListRows.Count > rowi + 1 Then
                    ASheet.Range(.DataBodyRange.Rows(rowi + 2), .DataBodyRange.Rows(.ListRows.Count)).Delete Shift:=xlUp
                End If
            End With
        End If
    ElseIf RegionExists(TableName) = True And Update = True And KeyColumn = "" Then
        If ShiftRows = True Then
            With ASheet.Range(TableName)
                If .Rows.Count < 2 Then waszero = True
                If .Rows.Count < TotalRange.Rows.Count Then
                    .cells(2).Resize(TotalRange.Rows.Count - .Rows.Count).Insert Shift:=xlDown
                ElseIf .Rows.Count > TotalRange.Rows.Count Then
                    .Rows(TotalRange.Rows.Count + 1 & ":" & .Rows.Count).Delete Shift:=xlUp
                End If
            End With
        End If
    Else
        waszero = True
    End If
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

imagodei ::

o_0

Dobro, če služi namenu, potem je OK. Kaj hočeš naredit, veš najbolje ti.
- Hoc est qui sumus -

korenje3 ::


:)
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

Vazelin ::

Ful slabo se vidi saj imaš preveliko resolucijo.
I got 99 problems but 4 usd XTZ ain't one...

korenje3 ::

Ja res je... program ne omogoča 4k posnetkov :(
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W

Vazelin ::

Zakaj bi za prikaz desktopa rabil 4k lulz?
zakaj preprosto ne povečaš DPI lol
I got 99 problems but 4 usd XTZ ain't one...

Zgodovina sprememb…

  • spremenilo: Vazelin ()


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Excel: tiskanje po vrsticah

Oddelek: Pomoč in nasveti
7967 (880) luksorzi
»

[C#,SQL]

Oddelek: Programiranje
51154 (1067) JanOlMajti
»

c# datagridview in combox

Oddelek: Programiranje
131149 (1037) OmegaM
»

problem v C#

Oddelek: Programiranje
211890 (1605) dvojka
»

[Visual studio .NET] Rabim pomoč

Oddelek: Programiranje
91538 (1380) darkolord

Več podobnih tem