Excel 2010 vba arrays come errore membro di class

Sto lavorando ad un progetto e sono entrato in qualcosa che non capisco. Quando assegna un arrays a un membro della class, i nomi Let and Get non possono essere gli stessi. Se sono, ho l'errore:

Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter

Può qualcuno dirmi se sto facendo qualcosa di sbagliato, o se è proprio così. Il codice riportto di seguito genera il messaggio di cui sopra.

Codice test:

 Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub SubloadServer () Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub Dim testServer Come AvayaServer Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub Dim arr () Come variante Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub arr = Array ("1", "2", "3", "4", "5") Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub Impostare testServer = Nuovo AvayaServer Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub testServer.Name = "Questa succhia" Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub testServer.Skill = arr Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub MsgBox testServer.Skills (4) Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub MsgBox testServer.Name Sub loadServer() Dim testServer As AvayaServer Dim i As Long Dim arr() As Variant arr = Array("1", "2", "3", "4", "5") Set testServer = New AvayaServer testServer.Name = "This Sucks" testServer.Skill = arr MsgBox testServer.Skills(4) MsgBox testServer.Name End Sub 

Codice della class:

 Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property PName privato come string Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Private pSkills () come string Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Proprietà pubblica Prendi abilità () come variante Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Abilità = pSkills () Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Proprietà pubblica Lasciate le competenze (valori () come variante) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property ReDim pSkills (UBound (valori)) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Per i = LBound (valori) A UBound (valori) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property pSkills (i) = valori (i) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values() As Variant) ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property 

  • Inserire macro e cambiare l'image nell'intestazione tutti i fogli escono
  • Come posso aggiungere condizioni alla mia equazione quando si utilizza WorksheetFunction.MAX in VBA?
  • Spostare vari colonne in una colonna, ma lasciando una fila vuota tra di loro
  • Excel VBA: Trova il valore in un arrays multidimensionale
  • Come compilare i file Python 3.4 e Excel in .exe
  • Come posso inserire la formula nella cella quando la formula continua a cambiare con un aumento della row?
  • Come hide le righe che contengono un numero di un grande elenco di numbers di parte
  • Looping attraverso le celle visibili per eccellere per accedere all'inserto
  • One Solution collect form web for “Excel 2010 vba arrays come errore membro di class”

    Modifica values() As Variant ai values As Variant :

    Codice della class:

     Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property PName privato come string Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Private pSkills () come string Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Proprietà pubblica Prendi abilità () come variante Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Abilità = pSkills () Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Proprietà pubblica Lasciate le competenze (valori come variante) 'Fissi qui Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property ReDim pSkills (UBound (valori)) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property Per i = LBound (valori) A UBound (valori) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property pSkills (i) = valori (i) Private pName As String Private pSkills() As String Public Property Get Skills() As Variant Skills = pSkills() End Property Public Property Let Skills(values As Variant) 'Fixed here ReDim pSkills(UBound(values)) Dim i As Long For i = LBound(values) To UBound(values) pSkills(i) = values(i) Next End Property 

    Spiegazione:

    values As Variant sarà di tipo Variant , che più tardi si utilizza per memorizzare un arrays. values() As Variant è un arrays di Variant di tipo, a cui non è ansible assegnare un Array ; un Array può essere assegnato solo al primo.

    Microsoft Office Excel Spreadsheet è il miglior software di Office, Excel VBA e formule Excel rendono il foglio di calcolo più veloce.