?
Solved

evaluating an expression containing a reference to an array

Posted on 2003-02-25
12
Medium Priority
?
214 Views
Last Modified: 2010-05-01
For x = 1 To 7
NameArray(x).Visible = False
Next x

ok, i dunno where else to ask. how do i evaluate "namearray(x)" so that the expression evaluates proparly?
0
Comment
Question by:Rusch
[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
  • 2
  • 2
  • 2
  • +5
12 Comments
 

Author Comment

by:Rusch
ID: 8017756
i feel stupid, but i really need to know fast..
0
 
LVL 2

Accepted Solution

by:
NPluis earned 152 total points
ID: 8017898
I'm not quite sure what you want to do. IS NameArray an array of controls on your form and you want to hide them but then?

Could you rephrase your question?
0
 

Expert Comment

by:e-Diddy
ID: 8018162
If NameArray is a valid form Array this should work. I have some of the same questions that NPluis had before but you can take this into consideration.

Try this to initialize the For

For x = 0 To NameArray.Ubound

form arrays start at 0 (default) and this will make sure you do not loop past the array

Everything else looks ok Though...if NameArray is actually a Form Array
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 8018509
If NameArray is a control array, the controls may not have consecutive indexes - for example, only NameArray(0), NameArray(1), and NameArray(10) may be valid.

Place On Error Resume Next before the loop and On Error Goto 0 after the loop to ignore errors caused by missing members.
0
 
LVL 5

Expert Comment

by:jayeshshah
ID: 8019143
this would not be possible in Visual Basic to evaluate expressions. Though it;s possible in Foxpro and Java (eval fucntion), I have not heard about it in Visual Basic.

K'Regards

Jayesh
0
 

Expert Comment

by:e-Diddy
ID: 8019181
jayeshshah--
 I think you can emulate the eval method in VB by using the CallByName function.
0
 

Author Comment

by:Rusch
ID: 8021029
Ok, NameArray(10) is simply an array I've filled with text strings. These strings correspond to Frames that I've created in Visual Basic. It's all in one actual Form, and what I'm trying to do is simply hide certain Frames and the display one. Since I've not been able to evaluate that one string, this is how I've solved it temporarily:

Private Sub Command1_Click()
WelcomeForm.Visible = False 'hides form
AddForm.Visible = True 'shows form
AlterForm.Visible = False 'hides form
DelForm.Visible = False 'hides form
ViewRecordsForm.Visible = False 'hides form
ViewStatsForm.Visible = False 'hides form
ProgSettingsForm.Visible = False 'hides form
Call AddARecord 'starts this menu-option
End Sub

WelcomeForm, AddForm, etc.. are my entries in NameArray(10). Ignore the *Form name I've given them, because they're not actually forms, but frames. Coming from a lot of JavaScript usage, I thought this would be a simple way of minimizing coding.

I hope this helps understand my question. Thank you.
0
 

Assisted Solution

by:RMatzka
RMatzka earned 148 total points
ID: 8021237
Create the frames as an array of frames. I.e., all your frames have the same Name property (e.g. "FrameArray") and only differ by their Index property. Then the following code works:

For x = 1 To 7
  FrameArray(x).Visible = False
Next x

If, on the other hand, you need to distinguish forms by their meaning, declare an enum type, like this:
Private Enum FrameName
  WelcomeForm
  AddForm
  AlterForm
  DelForm
  ViewRecordsForm
  ViewStatsForm
  ProgSettingsForm
End Enum
Then you can write code like
FrameArray(DelForm).Visible=True
0
 
LVL 2

Expert Comment

by:NPluis
ID: 8023603
I think what you want is this:

for x = 0 to 7
  Me.Controls(NameArray(x)).Visible = False
next

This is to hide alle of them. To show 1 you can use Me.Controls(NameArray(x)).Visible = True

0
 

Expert Comment

by:CleanupPing
ID: 8901132
Rusch:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8972796
Moderator, my recommended disposition is:

    Split points between: NPluis and RMatzka

DanRollins -- EE database cleanup volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

764 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