how can I dynamically dimension objects in a loop ?
trying to do something like this -but it doesn't compile
for i = 1 to 5
Dim "submenu" & i As New objectName_here
next
Compiler Error Message: BC30203: Identifier expected. 7 922
Hi TJS
That one is absolutely impossible, but i can suggest you can alternate way of doing in the same way, that is identifying the objects with some name
look at the following code
Dim ht As New Hashtable(
Dim i As Intege
For i = 0 To
ht.Add("Obj" & i, "" & i
Nex
MsgBox(CType(ht("Obj1"), String)
But remember the key is case sensitive
I hope that this could help u a little
Sadha Sivam
Microsoft Community Star
Malleable Minds Software Pvt Ltd., India as******@yahoo.co
You could probably do this using the CodeDOM but it would be non-trivial.
Have you thought about using an array (or a collection) like:
Dim a(4) As objectName
For i As Integer = 0 to 4
a(i) = New objectName(...)
Next
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"TJS" <no****@here.com> wrote in message
news:O3**************@tk2msftngp13.phx.gbl... how can I dynamically dimension objects in a loop ?
trying to do something like this -but it doesn't compile
for i = 1 to 5 Dim "submenu" & i As New objectName_here next
Compiler Error Message: BC30203: Identifier expected.
Hi TJS,
Before you get confuse, although the one from Rob is simpler, I would try
the sample TJS did give you. When you only reference them by index you can
also use the arraylist as an alternative, however the sample from TJS is
better in my opinion.
Just to help you choose.
Cor
I tried your suggestion but it does not allow me to convert object to a
string
"Rob Windsor [MVP]" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl... You could probably do this using the CodeDOM but it would be non-trivial. Have you thought about using an array (or a collection) like:
Dim a(4) As objectName For i As Integer = 0 to 4 a(i) = New objectName(...) Next
-- Rob Windsor [MVP-VB] G6 Consulting Toronto, Canada
"TJS" <no****@here.com> wrote in message news:O3**************@tk2msftngp13.phx.gbl... how can I dynamically dimension objects in a loop ?
trying to do something like this -but it doesn't compile
for i = 1 to 5 Dim "submenu" & i As New objectName_here next
Compiler Error Message: BC30203: Identifier expected.
how do I set this to an object ?
"Sadha Sivam S" <as******@yahoo.com> wrote in message
news:08**********************************@microsof t.com... Hi TJS,
That one is absolutely impossible, but i can suggest you can alternate way
of doing in the same way, that is identifying the objects with some name. look at the following code.
Dim ht As New Hashtable() Dim i As Integer For i = 0 To 5 ht.Add("Obj" & i, "" & i) Next MsgBox(CType(ht("Obj1"), String))
But remember the key is case sensitive.
I hope that this could help u a little.
Sadha Sivam S Microsoft Community Star, Malleable Minds Software Pvt Ltd., India, as******@yahoo.com
* "TJS" <no****@here.com> scripsit: I tried your suggestion but it does not allow me to convert object to a string
?!?
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
I'm sorry, I don't know what you mean by this statement.
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"TJS" <no****@here.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl... I tried your suggestion but it does not allow me to convert object to a string
"Rob Windsor [MVP]" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message news:ux**************@tk2msftngp13.phx.gbl... You could probably do this using the CodeDOM but it would be
non-trivial. Have you thought about using an array (or a collection) like:
Dim a(4) As objectName For i As Integer = 0 to 4 a(i) = New objectName(...) Next
-- Rob Windsor [MVP-VB] G6 Consulting Toronto, Canada
"TJS" <no****@here.com> wrote in message news:O3**************@tk2msftngp13.phx.gbl... how can I dynamically dimension objects in a loop ?
trying to do something like this -but it doesn't compile
for i = 1 to 5 Dim "submenu" & i As New objectName_here next
Compiler Error Message: BC30203: Identifier expected.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gaubitzer Erwin |
last post by:
Hi there
I wrote a short program which reads scientific data from
a file and stores its values in a Numeric array.
At the same time it reads the names of its dimensions which
are then in the...
|
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 |
last post by:
(see end of message for example code)
When an instance has a dynamically assigned instance method, deepcopy
throws a TypeError with the message "TypeError: instancemethod
expected at least 2...
|
by: Sara |
last post by:
I am trying to find the average number of products of the set that is
on rows...dynamically.
For example, if I had states on rows and was looking at the average
number of products, I would see...
|
by: Fabian Wauthier |
last post by:
Hi list,
I am trying to dynamically grow a 2 dimensional array (Atom ***Screen) of
pointers to a struct Atom (i.e. the head of a linked list). I am not
sure if this is the right way to do it:
...
|
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 =...
|
by: Jon B |
last post by:
Hi There!
How to handle the events of a dynamically added user control?
e.g. I have following code...
Dim myUserControl as Object = LoadControl("myFirstControl.ascx")
myFirstControl fires...
|
by: tg |
last post by:
How can I sort a two-dimension array on the first dimension in the array?
If there's not a way to do it, how can I return the values of the first
dimension so that I can sort the values myself...
|
by: Nathan Sokalski |
last post by:
I have a multidimensional array declared as the following:
Dim guesses(14, 5) As Integer
I want to assign all values in a specific dimension to another array
declared as follows:
|
by: lovecreatesbea... |
last post by:
Is it always legal to cast expressions of type of multi-dimension
array to type of pointer?
Including:
T to T* ,
T to T* ,
T to T* ,
and so on...
For example:
int *mtxrot1d(int *p,...
|
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
|
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: 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...
|
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: 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...
|
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,...
| |