473,385 Members | 1,379 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,385 software developers and data experts.

Dynamically define variables in VB.Net/ASP.Net

SV
Hi there,

I am using ASP.Net 2.0 with VB.Net.

I want to define variables. For example I want to create variable of
type TableRow and while defining I don't know how many rows i needed.
So what i want to do in my code:

For i As Integer = 0 To dt.Tables(0).Rows.Count - 1
dim tr_i as New TableRow

' other code.....

Next i

But it will define variable as tr_i...but i want tr_0,
tr_1,tr_2,.........

Is it possible?

Thanks,

SV
Jun 27 '08 #1
5 1588
It is possible that you are not exactly on the right track. What do you want
to achieve?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"SV" <sw*******@gmail.comwrote in message
news:89**********************************@y18g2000 pre.googlegroups.com...
Hi there,

I am using ASP.Net 2.0 with VB.Net.

I want to define variables. For example I want to create variable of
type TableRow and while defining I don't know how many rows i needed.
So what i want to do in my code:

For i As Integer = 0 To dt.Tables(0).Rows.Count - 1
dim tr_i as New TableRow

' other code.....

Next i

But it will define variable as tr_i...but i want tr_0,
tr_1,tr_2,.........

Is it possible?

Thanks,

SV

Jun 27 '08 #2
This is called an Array. I would suggest to read at least once the language
specification so that you have an idea of what you have at your disposal...

You may want also to explain what you are trying to do (This is a datarow,
not a tablerow, you can browse each row using for each. You already have
this array using dt.Tables(0).Rows(i) etc....)
--
Patrice

"SV" <sw*******@gmail.coma écrit dans le message de groupe de discussion :
89**********************************...oglegroups.com...
Hi there,

I am using ASP.Net 2.0 with VB.Net.

I want to define variables. For example I want to create variable of
type TableRow and while defining I don't know how many rows i needed.
So what i want to do in my code:

For i As Integer = 0 To dt.Tables(0).Rows.Count - 1
dim tr_i as New TableRow

' other code.....

Next i

But it will define variable as tr_i...but i want tr_0,
tr_1,tr_2,.........

Is it possible?

Thanks,

SV

Jun 27 '08 #3
"SV" <sw*******@gmail.comwrote in message
news:89**********************************@y18g2000 pre.googlegroups.com...
Is it possible?
As others have mentioned, dynamic variables are possible in .NET but are
generally considered to be poor programming practice.

There will almost certainly be much more efficient methods - can you explain
a bit more about what you're trying to do...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
SV
Thanks all for your replies.

I think I was not able to explain you very well. But I tried to do the
things using arrays but didn’t get exactly what I want.
Anyways, I have solved the problem.

I really appreciate your precious replies.
Thanks.

On May 20, 6:28*pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"SV" <swetav...@gmail.comwrote in message

news:89**********************************@y18g2000 pre.googlegroups.com...
Is it possible?

As others have mentioned, dynamic variables are possible in .NET but are
generally considered to be poor programming practice.

There will almost certainly be much more efficient methods - can you explain
a bit more about what you're trying to do...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Jun 27 '08 #5
re:
!Anyways, I have solved the problem

It could help others if you posted the solution you arrived at.
Sharing information like that is the very purpose of these newsgroups.

Can you ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espańol : http://asp.net.do/foros/
======================================
"SV" <sw*******@gmail.comwrote in message news:1b**********************************@u36g2000 prf.googlegroups.com...
Thanks all for your replies.

I think I was not able to explain you very well. But I tried to do the
things using arrays but didn’t get exactly what I want.
Anyways, I have solved the problem.

I really appreciate your precious replies.
Thanks.

On May 20, 6:28 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"SV" <swetav...@gmail.comwrote in message

news:89**********************************@y18g2000 pre.googlegroups.com...
Is it possible?

As others have mentioned, dynamic variables are possible in .NET but are
generally considered to be poor programming practice.

There will almost certainly be much more efficient methods - can you explain
a bit more about what you're trying to do...?

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Jun 27 '08 #6

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

Similar topics

10
by: junky_fellow | last post by:
What is the correct way of dynamically allocating a 2d array ? I am doing it the following way. Is this correct ? #include <stdlib.h> int main(void) { int (*arr)(3); arr =...
5
by: kw | last post by:
My aspx dynamically loads an ascx into a placeholder. The ascx has an event. When I click on the submit linkbutton in the ascx, the event does not fire. But if I click it a second time, it...
9
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
5
by: Angel | last post by:
Is there a way to create an IFRAME dynamically via VB.NET. In other words creating the HTML element in the server side code? thanks in advance....
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
5
by: tricard | last post by:
Good day all, I have created a two dimensional array (matrix for my purposes) whose size is dynamically allocated. (i.e. rowSize and colSize are both taken as input, then malloc() is used to...
1
by: dnn | last post by:
How can I access dynamically loaded variables? I am trying to load an external javascript file dynamically and then access its variables. The script is loaded by the onload handler. The code...
1
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function ////////////////////////////////////////////////////////////////////////////////////...
11
by: Nadeem | last post by:
Hello all, I'm trying to write a function that will dynamically generate other functions via exec. I then want to be able to import the file (module) containing this function and use it in other...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.