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

creating an array at runtime

hello all
how to create an array at runtime in vb
Mar 22 '08 #1
4 1835
kadghar
1,295 Expert 1GB
hello all
how to create an array at runtime in vb
yo cannot create it at run time, you must have it already defined. But, you can define it as:

dim MyArr()

and then, during runtime, you can ReDim it:

ReDim MyArr(1 to n, 1 to m)

You can also have a Variant, and if you asign some list, range, collection, etc to it, it'll become a Variant's array.

HTH
Mar 24 '08 #2
jg007
283 100+
depends what type of array you mean , I have used the code below to create and array of labels on runtime

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2. Public Mylabel(4) As System.Windows.Forms.Label
  3.  
  4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.  
  6.  
  7.         Dim n As Integer
  8.  
  9.         ' text for diverted tasks
  10.         Dim Div_text(4) As String
  11.         Div_text(1) = "A"
  12.         Div_text(2) = "B"
  13.         Div_text(3) = "C"
  14.         Div_text(4) = "D"
  15.  
  16.         'add labels to array
  17.  
  18.         For n = 1 To 4
  19.             Mylabel(n) = New System.Windows.Forms.Label
  20.         Next n
  21.  
  22.         ' set up label size and location 
  23.  
  24.         For n = 1 To 4
  25.             Mylabel(n).Text = New String(Div_text(n))
  26.             Mylabel(n).Location = New System.Drawing.Point(200, (22 * n) - 10)
  27.  
  28.          ' add label to form
  29.  
  30.             Me.Controls.Add(Mylabel(n))
  31.         Next 
  32.  
  33.     End Sub
Mar 24 '08 #3
kadghar
1,295 Expert 1GB
depends what type of array you mean , I have used the code below to create and array of labels on runtime
Oh, that's true, you can make 'arrays' of controls during runtime. May be they can be more helpful for what you need, rekhamanoj!

Just have in mind that controls might be slower than variables. But for small amounts of data, it can be a nice solution.
Mar 24 '08 #4
thank you so much for your timely help
Mar 31 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Venkatesh | last post by:
Hi Everybody, This is the first timw I am entering into this Group. I am developing a VB Project with an MDI form. I want to display IE Favorites into my application. For this I need to...
2
by: Pablo | last post by:
Hi people, Necesito crear n dataviews en tiempo de ejecucion. I need to create "n" DataViews in runtime. I tried creating an array this way: Dim LDView As Array =...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
2
by: Ranier Dunno | last post by:
Hi, I'd like to create typed arrays during runtime, sort of like this: Array vals = Array.CreateInstance(objType, noElements); The problem is that objType will not be a "base" type like...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
9
by: mupe | last post by:
Hi, i have a problem with a Type Library, which is written in C++. I am developing an application in C#.NET and have to use functions from this COM-Type Library. When I use these functions in...
30
by: josh | last post by:
Hi all, what does it meaning that strange sintax (look at the object :) ? if I have i.e. array.length I can use array. and is it IE/Firefox compatible??
15
by: Madhur | last post by:
Hi All, I would like you help me in creating an array of data types. I am interested in look at the the data type which looks like this Array...
2
by: nitinm | last post by:
hi I want to make a program whose requirement are as following: 1) it has to create an NxN matrix after reading input (i.e. N) from a file in the main() itself. 2) it has to send the array as...
2
by: oswald.harry | last post by:
hi i am reading a set of jpeg files(RGB) and extracts the pixel values as longs.i want to create a 2d array with numof rows=numof images and numof cols=numof pixels in each image.ie each row of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.