I'm using Visual Studio .NET 2002
I remember there was a way to do this in C, so there should be a way of
doing it in .NET:
Instead of:
Dim bolSquare1 as Boolean
Dim bolSquare2 as Boolean
Dim bolSquare3 as Boolean
|
|
|
Dim bolSquare9 as Boolean
Is there some way of doing it like this:
Dim i as Integer
For i = 1 to 9
Dim bolSquare(i) as Boolean
Next
Any help is MUCH appreciated.
Peace,
LedZep 7 9613
<wa*********@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... I'm using Visual Studio .NET 2002
Upgrade. You are now two versions behind.
For i as Integer = 0 to 9
'whatever
Next
Works as of .NET 1.1 (VS2003).
David
Upgrade ::: You missed the correct interpretation of his question :-)
he wants to dynamicly declare ( create variabels ) in a loop
Michel Posseth [MCP]
"David Browne" wrote: <wa*********@hotmail.com> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com... I'm using Visual Studio .NET 2002
Upgrade. You are now two versions behind.
For i as Integer = 0 to 9 'whatever Next
Works as of .NET 1.1 (VS2003).
David
you can dynamicly create an array of anny type like this
Dim items As Integer = 10
Dim bolSquare(items) As Boolean
MsgBox(bolSquare(1))
MsgBox(bolSquare(2))
MsgBox(bolSquare(3))
etc etc
so in items you can put the required numeber of items
isn`t that not much easier and cleaner code ?
regards
Michel Posseth [MCP]
"wa*********@hotmail.com" wrote: I'm using Visual Studio .NET 2002 I remember there was a way to do this in C, so there should be a way of doing it in .NET:
Instead of:
Dim bolSquare1 as Boolean Dim bolSquare2 as Boolean Dim bolSquare3 as Boolean | | | Dim bolSquare9 as Boolean
Is there some way of doing it like this:
Dim i as Integer For i = 1 to 9 Dim bolSquare(i) as Boolean Next
Any help is MUCH appreciated.
Peace, LedZep
"M. Posseth" <MP******@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com... Upgrade ::: You missed the correct interpretation of his question :-)
he wants to dynamicly declare ( create variabels ) in a loop
Oops.
David
But I don't want to create an array--I want to create ten different
Boolean variables (ex. bol1, bol2, bol3, bol4, bol5, bol6, etc.) using
a For Next loop. I want to figure this out because if I have to declare
100 different variables all the same except with different numbers, why
can't I use some kind of loop?
M. Posseth wrote: you can dynamicly create an array of anny type like this
Dim items As Integer = 10 Dim bolSquare(items) As Boolean
MsgBox(bolSquare(1)) MsgBox(bolSquare(2)) MsgBox(bolSquare(3))
etc etc
so in items you can put the required numeber of items
isn`t that not much easier and cleaner code ?
regards
Michel Posseth [MCP] "wa*********@hotmail.com" wrote:
I'm using Visual Studio .NET 2002 I remember there was a way to do this in C, so there should be a way of doing it in .NET:
Instead of:
Dim bolSquare1 as Boolean Dim bolSquare2 as Boolean Dim bolSquare3 as Boolean | | | Dim bolSquare9 as Boolean
Is there some way of doing it like this:
Dim i as Integer For i = 1 to 9 Dim bolSquare(i) as Boolean Next
Any help is MUCH appreciated.
Peace, LedZep
I dont think you can name a variable at run time, I think you need it
predefined in the code.
That said, why do you want to use 100 different variables instead of an
array with 100 members? An array is usually by far the cleanest way to do
this, what is pecial about this situation that you want 100 different
variables floating about?
<wa*********@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... But I don't want to create an array--I want to create ten different Boolean variables (ex. bol1, bol2, bol3, bol4, bol5, bol6, etc.) using a For Next loop. I want to figure this out because if I have to declare 100 different variables all the same except with different numbers, why can't I use some kind of loop?
M. Posseth wrote: you can dynamicly create an array of anny type like this
Dim items As Integer = 10 Dim bolSquare(items) As Boolean
MsgBox(bolSquare(1)) MsgBox(bolSquare(2)) MsgBox(bolSquare(3))
etc etc
so in items you can put the required numeber of items
isn`t that not much easier and cleaner code ?
regards
Michel Posseth [MCP] "wa*********@hotmail.com" wrote:
I'm using Visual Studio .NET 2002 I remember there was a way to do this in C, so there should be a way
of doing it in .NET:
Instead of:
Dim bolSquare1 as Boolean Dim bolSquare2 as Boolean Dim bolSquare3 as Boolean | | | Dim bolSquare9 as Boolean
Is there some way of doing it like this:
Dim i as Integer For i = 1 to 9 Dim bolSquare(i) as Boolean Next
Any help is MUCH appreciated.
Peace, LedZep
i understand that
afaik : this is not possible the way you described it , i also don`t see
the point of not using a array in this case ( or a named collection , if you
prefer that )
regards
\
Michel Posseth [MCP]
"wa*********@hotmail.com" wrote: But I don't want to create an array--I want to create ten different Boolean variables (ex. bol1, bol2, bol3, bol4, bol5, bol6, etc.) using a For Next loop. I want to figure this out because if I have to declare 100 different variables all the same except with different numbers, why can't I use some kind of loop?
M. Posseth wrote: you can dynamicly create an array of anny type like this
Dim items As Integer = 10 Dim bolSquare(items) As Boolean
MsgBox(bolSquare(1)) MsgBox(bolSquare(2)) MsgBox(bolSquare(3))
etc etc
so in items you can put the required numeber of items
isn`t that not much easier and cleaner code ?
regards
Michel Posseth [MCP] "wa*********@hotmail.com" wrote:
I'm using Visual Studio .NET 2002 I remember there was a way to do this in C, so there should be a way of doing it in .NET:
Instead of:
Dim bolSquare1 as Boolean Dim bolSquare2 as Boolean Dim bolSquare3 as Boolean | | | Dim bolSquare9 as Boolean
Is there some way of doing it like this:
Dim i as Integer For i = 1 to 9 Dim bolSquare(i) as Boolean Next
Any help is MUCH appreciated.
Peace, LedZep
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Trevor Best |
last post by:
I did a test once using a looping variable, first dimmed as Integer,
then as Long. I found the Integer was quicker at looping. I knew this to
be true back in the 16 bit days where the CPU's (80286)...
|
by: Tim Anderson |
last post by:
Is this expected behavior?
Winform with button and listbox:
Dim i As Integer
For i = 0 To 50
Dim s As String
If i = 1 Then
s = "Only once?"
End If
|
by: Oliver Corona |
last post by:
I am wondering if anyone has any insights on the performance benefit (or
detriment) of declaring local variables instead of referencing members. Is
allocating memory for a new variable more...
|
by: CR |
last post by:
I've noticed that the trend these days is to declare variables in the
middle of code instead of at the top. What is the advantage of this?
It seems like it makes it hard to reuse variables.
Here...
|
by: jhightow |
last post by:
The following code :
For i as system.Int32 = 0 to 4
If i < 2 Then
Dim s as System.String
s &= i.ToString
Console.WriteLine(s)
End If
Next
|
by: rendle |
last post by:
I have a MSIL/performance question:
Is there any difference between declaring a variable once and assigning
to it multiple times, and declaring and assigning multiple times?
For example:
//...
|
by: SM |
last post by:
I've always wonder if there is diference when declaring and
initializing a varible inside/outside a loop.
What's a better practice?
Declaring and initializing variables inside a loop routine,...
|
by: =?Utf-8?B?QUw=?= |
last post by:
Hi
I usually stick to the convention of not declaring variables in my bodies of
"loops" (including foreach)
ie
int x;
for (int i = 0; i < 10; i++) {
|
by: AZRebelCowgirl73 |
last post by:
This is what I have so far:
My program!
import java.util.*;
import java.lang.*;
import java.io.*;
import ch06.lists.*;
public class UIandDB {
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
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,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |