How do,
I want to be able to make a certain number of variables depending on the number of data items i have to be used.
For example, i would need 3 variables defined when i have 3 numbers and 5 variables when i have 5 numbers.
Is there any way in the VBA that I can define variables with variables in the name (ie: Dim Number & x as Double within a For Next loop). I can do this with the text boxes on the form, so I was wondering if I could do it with defining variables.
I want to do it this way as the numbers are the overall Lap Time in a race and need to be assigned points (eg: 1st = 5 points 2nd = 3 points etc) and there is the possibility of any number of Race Times to be compared.
Obviously if you have any other ideas they are much appreciated.
Thanks in advance,
NDayave
7 8166 ADezii 8,834
Recognized Expert Expert @NDayave
Don't think that this can be done, but what about a Dynamic Array to store the values, something like: - Dim lngCounter As Long
-
Const conNUM_OF_RACES As Long = 4
-
-
Dim alngRaces() As Long
-
-
ReDim alngRaces(1 To 4)
-
-
For lngCounter = 1 To conNUM_OF_RACES
-
alngRaces(lngCounter) = lngCounter ^ 3
-
Next
-
-
'Playback the elements in the Array
-
For lngCounter = LBound(alngRaces) To UBound(alngRaces)
-
Debug.Print alngRaces(lngCounter)
-
Next
OUTPUT:
Thanks for the input,
This appears to do what I need, the ReDim statement is what I was after.
These kind of things are impossible to google.
Thanks again,
NDayave
nico5038 3,080
Recognized Expert Specialist
ReDim is a rather "costly" statement.
An alternative to using arrays is to switch to using collections. These don't require a ReDim and can be processed using a For Next loop.
Nic;o)
ADezii 8,834
Recognized Expert Expert @nico5038
Hello Nico, just for curiosity, are you saying that it would be faster to dynamically Add/Remove Items from a Collection as opposed to dynamically Resizing an Array?
nico5038 3,080
Recognized Expert Specialist
The ReDim is "costly" because memory has to be re-allocated. A Collection holds coded methods to add/remove items and the FOR NEXT will make processing easy.
Saw a nice piece of loop time testing by you in the "Insights" section, perhaps worthwhile to re-use <LOL>
Nic;o)
ADezii 8,834
Recognized Expert Expert @nico5038
Thanks for the explanation Nico, always a learning experience around here (LOL).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: PHP2 |
last post by:
I have one large number with 18 decimal places for license key. have any way
that I transfer my number into shorter number or string with some method?
|
by: chrispycrunch |
last post by:
How do I output a row number for a table solely for the purpose of
querying for a unique row?
In my problem, the table from a legacy system does not have a primary
key, so it limits various querying I'd like to do that identifies
uniqueness in the table.
The problem is that since I'm using DTS to simply copy the table to
SQL, I don't want to create identity rows.
|
by: Tom Cusick |
last post by:
We have a Job Shop database. When I get an order in I put all the
line item information into the database. Some orders have multiple
lines and most of the information is the same. (eg. Customer Name, PO,
Due Date, Received, etc.)
2 questions:
1. I have a button to create a new record on my switchboard, but what
I would like that button to do is create a new record but enter in the
next job number. Our job numbers are 'H1001', so I...
|
by: skinnybloke |
last post by:
Hi
I have written 3 seperate macros in access to run 3 queries to
export 3 .xls files.
Sometimes I will need to run them individually.
Sometimes I will need to run them all together therefore I have
written a top level macro to run the 3 macros.
|
by: brian.a.kennedy |
last post by:
I am a rookie and am looking to create records based on a field value.
For example - I currently have sales data for three employees:
Employee 1 has sold 12 units, EE 2 has 8 and EE 3 has 10....I want to
create a table that will show 30 records instead of 3 and list the
employee infor as well as the order #. Any advice?
| |
by: Mr. Ken |
last post by:
Sorry for the non-C++ topic, but it's most easy to get answer from here I
guess.
How do I create random numbers (integer from 0~9999) in Unix C-shell?
I am writing a script which randomly selects some files among file bank and
sent to processing.
Now the random selection part bogs me down.
|
by: Arne Beruldsen |
last post by:
I have a windows app using vb.net 2005.
I would like to create a serial number based on a couple of characteristics
of the customers computer (computer name, HD number..etc). I don't need
anything complicated just a way to generate a 16 character number.
Is there an easy way to do this...?
Thanks
|
by: Deven Oza |
last post by:
Hello everyone
please help me to Write a complete program USING EITHER FOR LOOP OR A WHILE LOOP that will display the first n numbers of the following infinite sequence:
1 , 3 , 6 , 10 , 15 , 21 , 28 , 36 , 45 , . . .
The program is to be written such that the user will enter a positive integer n , representing the number of elements of the sequence that the user wants displayed, and then these n sequence numbers are displayed in a...
|
by: nickyazura |
last post by:
Hi,
I would like to ask you regarding creating file name by adding unique number where it can automatically generated
Dim sFileE As String
sFileE = ".csv"
sFileName = "Weld_In_Record" & Format(Now, "yyyymmdd") & sFileE
after run, i can get a result of Weld_In_Record20080304.csv
here, i want to add more by putting other sequential unique number
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |