Solved

variables between another variables

Posted on 2000-03-01
5
145 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…

830 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