Solved

variables between another variables

Posted on 2000-03-01
5
147 Views
Last Modified: 2010-05-02
How can use counter between another variable?

If I have ten forms (form1...form10)
example:

for i = 1 to 10

  form&i.refresh ??

next

Thanks in advance!
0
Comment
Question by:majala
[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
5 Comments
 
LVL 1

Accepted Solution

by:
PatrickVD earned 50 total points
ID: 2572071
The code you actually typed, is not possible in VB.
VB does not support MACRO expansion (as it used to be in the late Clipper and other languages)
Actually you can't use a variable in another variable's name :-(

What you CAN do to solve your current problem is to cycle through the Forms collection at runtime and check the Form.Name property to match your criteria :

for i = 0 to (Forms.Count - 1)

  If Forms(i).Name = ("Form" & CStr(i)) Then
     Form(i).Refresh
  End If
next


This will work perfectly....

Hope this helps ya out !
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2572074
This is not really an answer to your general question, but you could use the forms collection to achieve what you are trying to do in the example :

Dim frmTemp as form

For Each frmTemp in Forms
    frmTemp.Refresh
Next frmTemp

Hope that helps.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2572076
Sorry PatrickVD - your comment appeared while I was submitting mine !
0
 
LVL 13

Expert Comment

by:crazyman
ID: 2572077
dim f as form
for each f in forms
    f.refresh
next f
0
 
LVL 13

Expert Comment

by:crazyman
ID: 2572080
Sorry all ..yours appeared while i was submitting mine ...LOL
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

717 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