Solved

variables between another variables

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now