Solved

variables between another variables

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

778 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