Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Initializing structure variables

Posted on 2008-06-19
1
Medium Priority
?
136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 1155 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 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