PC Review


Reply
 
 
=?Utf-8?B?U8O2cmVuX01hcm9kw7ZyZW4=?=
Guest
Posts: n/a
 
      25th Jan 2007
Hi,

I want to declare some arrays of constants.
One array has 5 elements as String, and some other arrays can have up to 100
elements as Single.
Can I do it in a single statement like: "Const InterestRate as Single =
0.07" but with allot more data?
Or do I have to first define a variable "Dim InterestRate (1 To 100) as
Single" and then assigning it by "InterestRate =
Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)


Best regards,
/Sören
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      25th Jan 2007
I don't think that you can do it in the declaration, you need to dim it and
then assign it.

But just dim it as a variant variable, don't bound it.

Dim InterestRate

InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" <(E-Mail Removed)> wrote in message
news:F1FA9197-F029-4B6F-9CBD-(E-Mail Removed)...
> Hi,
>
> I want to declare some arrays of constants.
> One array has 5 elements as String, and some other arrays can have up to
> 100
> elements as Single.
> Can I do it in a single statement like: "Const InterestRate as Single =
> 0.07" but with allot more data?
> Or do I have to first define a variable "Dim InterestRate (1 To 100) as
> Single" and then assigning it by "InterestRate =
> Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)
>
>
> Best regards,
> /Sören



 
Reply With Quote
 
=?Utf-8?B?U8O2cmVuX01hcm9kw7ZyZW4=?=
Guest
Posts: n/a
 
      25th Jan 2007
I have found a better soulution:

Dim InterestRate As Variant 'Not needed to do
InterestRate = Array(0.07, 0.071, 0.06, 0.063, 0.055, 0.059)

The Array function is new for me, but I found it in the book 'Excel 2003
Power Programming with VBA', by John Walkenbach, page 295.

BR,
/Sören

"Bob Phillips" wrote:

> I don't think that you can do it in the declaration, you need to dim it and
> then assign it.
>
> But just dim it as a variant variable, don't bound it.
>
> Dim InterestRate
>
> InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")
>
> --
> ---
> HTH
>
> Bob
>
> (change the xxxx to gmail if mailing direct)
>
>
> "Sören_Marodören" <(E-Mail Removed)> wrote in message
> news:F1FA9197-F029-4B6F-9CBD-(E-Mail Removed)...
> > Hi,
> >
> > I want to declare some arrays of constants.
> > One array has 5 elements as String, and some other arrays can have up to
> > 100
> > elements as Single.
> > Can I do it in a single statement like: "Const InterestRate as Single =
> > 0.07" but with allot more data?
> > Or do I have to first define a variable "Dim InterestRate (1 To 100) as
> > Single" and then assigning it by "InterestRate =
> > Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)
> >
> >
> > Best regards,
> > /Sören

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      25th Jan 2007
Better? Different yes, but not necessarily better.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" <(E-Mail Removed)> wrote in message
news:94A6BB29-2740-4C3B-9BC0-(E-Mail Removed)...
>I have found a better soulution:
>
> Dim InterestRate As Variant 'Not needed to do
> InterestRate = Array(0.07, 0.071, 0.06, 0.063, 0.055, 0.059)
>
> The Array function is new for me, but I found it in the book 'Excel 2003
> Power Programming with VBA', by John Walkenbach, page 295.
>
> BR,
> /Sören
>
> "Bob Phillips" wrote:
>
>> I don't think that you can do it in the declaration, you need to dim it
>> and
>> then assign it.
>>
>> But just dim it as a variant variable, don't bound it.
>>
>> Dim InterestRate
>>
>> InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>> (change the xxxx to gmail if mailing direct)
>>
>>
>> "Sören_Marodören" <(E-Mail Removed)> wrote in
>> message
>> news:F1FA9197-F029-4B6F-9CBD-(E-Mail Removed)...
>> > Hi,
>> >
>> > I want to declare some arrays of constants.
>> > One array has 5 elements as String, and some other arrays can have up
>> > to
>> > 100
>> > elements as Single.
>> > Can I do it in a single statement like: "Const InterestRate as Single =
>> > 0.07" but with allot more data?
>> > Or do I have to first define a variable "Dim InterestRate (1 To 100) as
>> > Single" and then assigning it by "InterestRate =
>> > Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)
>> >
>> >
>> > Best regards,
>> > /Sören

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want a const array... Sinex Microsoft C# .NET 3 10th Aug 2005 07:51 PM
how to declare Pub Const String Array ? dick Microsoft Excel Programming 1 24th Jun 2005 06:56 PM
Declaring a const array Edward Diener Microsoft C# .NET 2 10th Feb 2005 06:18 PM
VBA: const with array jfp Microsoft Access Form Coding 1 6th Sep 2003 04:51 AM
how do i declare const array? George Ter-Saakov Microsoft ASP .NET 4 22nd Aug 2003 05:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 AM.