473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Execute() alternative ?

Hello, all

I am currently doing the following:

lblPrice1.Text = arrPrices(1)
lblPrice2.Text = arrPrices(2)
lblPrice3.Text = arrPrices(3)
lblPrice4.Text = arrPrices(4)
lblPrice5.Text = arrPrices(5)

But I'd like to change it so it is done dynamically. I would like to
do something like:

Dim NUMPRODUCTS As Integer = 5
For i As Integer = 1 To NUMPRODUCTS
Execute( "lblPrice" & i & ".Text = arrPrices(" & i & ")" )
Next

I've read that I can do a complicated process of saving the code as a
DLL and then executing it, but I'd prefer a built-in function. Any
pointers?

Thanks,
Morgan Seppy
Nov 21 '05 #1
1 975
Morgan,

There are more posibilities for your problem:
1 name your tags accoording to the way you want to fill it and use that in a
for each loop
2 name your labelnames accoording to the way you want to fill it
3 create an control array with the references and use that
4 etc.

I give you an example of the 3th, typed here so watch typos and not tested
\\\
Dim lbls As Label() = New Label() {nothing,LblPrice1,lblPrice2, etc...5}
for i as integer = 1 to 5
lbls(i) = arrPrices(i)
next
///
One of the big advantage from this one is that the label can (also) be on
different containers withouth doing more loops.

It is easier by the way to go in VBNet to zero indexers. Those are not
logical in my opinion, however. only the typical VB namespace methods use
the one type indexers and this is for many of us confusing.

I hope this helps?

Cor

"Morgan" <ms****@gmail.com>
Hello, all

I am currently doing the following:

lblPrice1.Text = arrPrices(1)
lblPrice2.Text = arrPrices(2)
lblPrice3.Text = arrPrices(3)
lblPrice4.Text = arrPrices(4)
lblPrice5.Text = arrPrices(5)

But I'd like to change it so it is done dynamically. I would like to
do something like:

Dim NUMPRODUCTS As Integer = 5
For i As Integer = 1 To NUMPRODUCTS
Execute( "lblPrice" & i & ".Text = arrPrices(" & i & ")" )
Next

I've read that I can do a complicated process of saving the code as a
DLL and then executing it, but I'd prefer a built-in function. Any
pointers?

Thanks,
Morgan Seppy

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ravi | last post by:
Hi All, I am trying to execute a select statement using the DBI module of perl in a for loop. I am getting a strange behaviour, the select statement is excuting correctly only for the last element...
2
by: Rich Tasker | last post by:
My goal is to execute a DTS package that calls multiple child DTS packages from a C# (2003) app and display the progress of the entire process to the user. I have followed the model defined in...
6
by: Doohan W. | last post by:
Hi, I'm now working with DB2, and I can't find out how to execute the contents of a string Statement, without using a Java/... procedure, only using SQL statements. I know that some SQBDs such...
6
by: John Baker | last post by:
Hi: Does "On Open" code execute before or after related data is loaded? I want to test before the form appears on the screen to see if there is any data in the queryresult, and if there is not...
7
by: Lucas Sain | last post by:
Hi, How can I make a code in an event not execute in design time. I have a Baseform that has X code in the event "VisibleChanged". All my forms inherit from this form. The code in this event...
1
by: Allen | last post by:
I have installed the Updater Application Block, and then I should Deploy the QuickStarts. " Install the QuickStarts After you install the Updater Application Block, you should install the...
31
by: Manfred Kooistra | last post by:
If I have a document like this: <html> <head> <script language=javascript> window.location.href='file.php'; </script> </head> <body> body content
19
by: citronelu | last post by:
Is it possible to execute a binary string stored within a python script as executable code ? The script is run under Windows, and the binary code (a full executable file) is stored in a variable...
4
by: =?Utf-8?B?TEJU?= | last post by:
Good day, I would like to execute an external application from a web form created using ASP.Net. I'm using System.Diagnostics.Process. It works fine if it is notepad.exe but it is not able to...
17
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
I am trying to replace a huge chunck of code that currently I incorporate with an #Include directive. The program rarely has to flow through that code, so I thought it would be better if I used...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.