Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Static date Hernan Excel Discussion (Misc queries) 8 April 13th 08 05:12 PM
Static y-axis quattda Charts and Charting in Excel 2 September 4th 07 08:48 AM
static date Alan g1bdu Excel Worksheet Functions 2 July 3rd 07 12:35 AM
Static Now() function sike11 via OfficeKB.com Excel Discussion (Misc queries) 7 April 24th 07 03:47 PM
Static Row DY New Users to Excel 5 September 9th 05 12:36 AM


All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"