Re: Arrays. Beginner's question!
- From: "Saga" <antiSpam@xxxxxxxxxxxxx>
- Date: Mon, 26 Nov 2007 12:16:39 -0600
Note that in your original post you are already using a variant:
Dim K(1 to 4)
What Bob (and I) suggest is that instead of using a variant array, you use
a variant variable. You should avoid using variant types whenever possible.
This is one of those cases when a variant type is your friend.
Also note that Bob qualified the variant type by explicitly including "as variant"
in the dim statement, something that I neglected to do. Definitely recommended
doing it Bob's way <g>.
Regards
Saga
--
23, 22, 21, 20, 19, 18...
"Suzy" <not@valid> wrote in message news:474b04a7@xxxxxxxxxxxxxxxxxxxx
"Bob Butler" <noway@xxxxxxxxxxx> wrote in message news:eyaLnJFMIHA.5160@xxxxxxxxxxxxxxxxxxxxxxx
"Suzy" <not@valid> wrote in message news:474b0175$1@xxxxxxxxxxxxxxxxxxxx
Dim K(1 to 4)
...
K=Array(45,65,23,465)
What am I doing wrong please as I get "can't assign" error?
The Array function returns a single variant containing the array and you can't assign that to an
array of variants. Unfortunately VB doesn't have any great way of doing what you are trying to
do. The simplest would be to use:
Dim K As Variant
K=Array(45,65,23,465)
You can then use K(0) through K(3) to get the values
Thanks Bob. So basically I have to use a variant, which people have alawys advised strongly
against?
.
- References:
- Arrays. Beginner's question!
- From: Suzy
- Re: Arrays. Beginner's question!
- From: Bob Butler
- Re: Arrays. Beginner's question!
- From: Suzy
- Arrays. Beginner's question!
- Prev by Date: Re: Arrays. Beginner's question!
- Next by Date: Re: ADODB Guids
- Previous by thread: Re: Arrays. Beginner's question!
- Next by thread: Re: Arrays. Beginner's question!
- Index(es):
Relevant Pages
|