Solved

Initializing structure variables

Posted on 2008-06-19
1
128 Views
Last Modified: 2010-04-30
Hello!
I have a structure:
    Public Structure geardrive
        Public name As String
        Public gearaxis As Integer
        Public axison As Boolean
        Public speed As Double
        Public target As Double
    End Structure
and I initialize:
        Dim planets() As geardrive

The help files say I can initialize the variables on the same line, like this:
        planets().name = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"}

but it give me an error under the parentheses: number of indeces is less than number of dimensions

and an error under the first bracket: Expression expected.

If I do it individually, it works: planets(0).name = "mercury"

What am I doing wrong in the same line version?  

Thanks,
Joy
0
Comment
Question by:fudgekitten
1 Comment
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 385 total points
ID: 21828586
You can't do that and there is no convenient way to do what you want. Each member of the record and each record has to be set individually.

Kevin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now