Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use static arrays
Hello,
I would like to use the static declaration for an array. However I have some difficulties on the subject. Public Function KeysResult(aPResult, bSet As Boolean) As Variant '-------------------------------------------------------------------------' If bSet Then Static aResult(conTotalModules) As Boolean aResult = aPResult Else KeysResult = aResult End If End Function Public Function KeysDLine(aPDLines, bSet As Boolean) As Variant '------------------------------------------------------------------------' If bSet Then Static aDLines(conTotalModules) As Variant aDLines = aPDLines Else KeysResult = aDLines End If End Function This give an error like : <can't assign to array. Any idean how to solve this ? Many thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use static arrays
This worked for me
'-------------------------------------------------------------------------' Public Function KeysResult(aPResult, bSet As Boolean) As Variant '-------------------------------------------------------------------------' Static aResult If bSet Then ReDim aResult(conTotalModules) aResult = aPResult Else KeysResult = aResult End If End Function -- HTH Bob Phillips "François" wrote in message ... Hello, I would like to use the static declaration for an array. However I have some difficulties on the subject. Public Function KeysResult(aPResult, bSet As Boolean) As Variant '-------------------------------------------------------------------------' If bSet Then Static aResult(conTotalModules) As Boolean aResult = aPResult Else KeysResult = aResult End If End Function Public Function KeysDLine(aPDLines, bSet As Boolean) As Variant '------------------------------------------------------------------------' If bSet Then Static aDLines(conTotalModules) As Variant aDLines = aPDLines Else KeysResult = aDLines End If End Function This give an error like : <can't assign to array. Any idean how to solve this ? Many thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use static arrays
try like: Option Explicit Const TOTAL_MODULES = 3 Public Function KeysResult(Optional aInput) Static saResult() As Boolean On Error GoTo errH If Not IsMissing(aInput) Then If IsArray(aInput) Then If UBound(aInput) = TOTAL_MODULES Then saResult = aInput Else Err.Raise 13 End If Else Err.Raise 9 End If End If KeysResult = saResult Exit Function errH: KeysResult = CVErr(Err) End Function Sub test() ReDim aiok(1 To TOTAL_MODULES) As Boolean ReDim aier(1 To 2) As Boolean Dim v v = KeysResult(aiok) Stop v = KeysResult Stop v = KeysResult(aier) Stop End Sub -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam François wrote : Hello, I would like to use the static declaration for an array. However I have some difficulties on the subject. Public Function KeysResult(aPResult, bSet As Boolean) As Variant '--------------------------------------------------------------------- ----' If bSet Then Static aResult(conTotalModules) As Boolean aResult = aPResult Else KeysResult = aResult End If End Function Public Function KeysDLine(aPDLines, bSet As Boolean) As Variant '--------------------------------------------------------------------- ---' If bSet Then Static aDLines(conTotalModules) As Variant aDLines = aPDLines Else KeysResult = aDLines End If End Function This give an error like : <can't assign to array. Any idean how to solve this ? Many thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Static date | Excel Discussion (Misc queries) | |||
Static y-axis | Charts and Charting in Excel | |||
static date | Excel Worksheet Functions | |||
Static Now() function | Excel Discussion (Misc queries) | |||
Static Row | New Users to Excel |