making variables

Hi,
I have a question (maybe a stupid one)
I have too make some variables like
dim matrix5(5,5) as integer
dim matrix6(6,6) as integer
......
dim matrix10(10,10) as integer
this can be done but I want a shorter way like

dim str as string
dim i as integer

for i = 5 to 10
str = "matrix" & i.tostring
dim  str(i,i) as integer
next i

but this gives a error
is it possible to do somthing like this without a error
it is long ago but i think it could be make in dbase3
thanks for any response
0
andrews
5/11/2010 9:18:03 AM
dotnet.languages.vb 830 articles. 0 followers. Follow

5 Replies
606 Views

Similar Articles

[PageSpeed] 45

andrews wrote:
> I have a question (maybe a stupid one)
> I have too make some variables like
> dim matrix5(5,5) as integer
> dim matrix6(6,6) as integer
> .....
> dim matrix10(10,10) as integer
> this can be done but I want a shorter way like
>
> dim str as string
> dim i as integer
>
> for i = 5 to 10
> str = "matrix" & i.tostring
> dim  str(i,i) as integer
> next i
>
> but this gives a error
> is it possible to do somthing like this without a error
> it is long ago but i think it could be make in dbase3
> thanks for any response

What do you ultimately want to do with those arrays? A different type of 
variable might be more suitable.

You can have an array of arrays:

Dim a(10)(,) As Integer
For i = 5 To 10
    ReDim a(i)(i, i)
Next

although it makes me cringe to do that.

Or you could write a program to output the text you need to specify the 
variables and paste that into your code.

-- 
Andrew 


0
Andrew
5/11/2010 10:01:27 AM
Don't you know this one?

http://www.indyproject.org/Sockets/index.en.aspx


"andrews" <andrews@pandora.be> wrote in message 
news:hh9Gn.27239$dB2.10318@newsfe22.ams2...
> Hi,
> I have a question (maybe a stupid one)
> I have too make some variables like
> dim matrix5(5,5) as integer
> dim matrix6(6,6) as integer
> .....
> dim matrix10(10,10) as integer
> this can be done but I want a shorter way like
>
> dim str as string
> dim i as integer
>
> for i = 5 to 10
> str = "matrix" & i.tostring
> dim  str(i,i) as integer
> next i
>
> but this gives a error
> is it possible to do somthing like this without a error
> it is long ago but i think it could be make in dbase3
> thanks for any response
> 
0
Cor
5/11/2010 10:47:52 AM
What I want is that I can make many arrays of different dimensions on a 
easy (short) way.
Sorry, there is no satisfaction with the given answers.
Maybe it is impossible.
Thanks any way.
0
andrews
5/12/2010 6:29:55 AM
Andrew,

Sorry I pasted in the wrong answer.

Arrays of different dimensions is an old way.

Now those things are called collections or lists.

By instance
Dim myList as new List(of String)

is in fact an array of Strings,

Although there is also the oldest one in Net the ArrayList, which is in fact 
the base of those, which is an List(array) of objects

Success,

Cor

"andrews" <andrews@pandora.be> wrote in message 
news:JVrGn.19117$bq.9946@newsfe30.ams2...
> What I want is that I can make many arrays of different dimensions on a 
> easy (short) way.
> Sorry, there is no satisfaction with the given answers.
> Maybe it is impossible.
> Thanks any way.
> 
0
Cor
5/12/2010 7:47:49 AM
I would like to add to that that now in VB 10 there is also the option to 
create in a easy way a "true" matrix

XXXXXXXXXXXXXXXXXXXX
XXXXXX  XXXX   XXX  XXXX
XX XXXX  XXX  XXXXXXXXX
                XXXX XXXXXXXXXX
XXXX        XXXXXX

where every X could be of  a different datatype

You can acomplish this with a dictionary type and the new generic  Tuple 
class


HTH


Michel Posseth


"Cor Ligthert[MVP]" <Notmyfirstname@planet.nl> schreef in bericht 
news:Ohtorda8KHA.1560@TK2MSFTNGP02.phx.gbl...
> Andrew,
>
> Sorry I pasted in the wrong answer.
>
> Arrays of different dimensions is an old way.
>
> Now those things are called collections or lists.
>
> By instance
> Dim myList as new List(of String)
>
> is in fact an array of Strings,
>
> Although there is also the oldest one in Net the ArrayList, which is in 
> fact the base of those, which is an List(array) of objects
>
> Success,
>
> Cor
>
> "andrews" <andrews@pandora.be> wrote in message 
> news:JVrGn.19117$bq.9946@newsfe30.ams2...
>> What I want is that I can make many arrays of different dimensions on a 
>> easy (short) way.
>> Sorry, there is no satisfaction with the given answers.
>> Maybe it is impossible.
>> Thanks any way.
>> 

0
Michel
5/13/2010 10:13:15 AM
Reply:

Similar Artilces:

How do I make a "deleted" message disappear off the inbox list?
It gets a "strike-through" font but doesn't go away. "Torwin" <Torwin@discussions.microsoft.com> wrote in message news:EF26BB46-FF7E-45F6-9A24-67318C248161@microsoft.com... > It gets a "strike-through" font but doesn't go away. You have an IMAP account? Edit-Purge..... Yes, it is IMAP. And I have found one answer, it's under the View menu but in a not-obvious place: View | Arrange By | Current View | Hide Messages Marked for Deletion Thank you for your reply Gordon, is this what you were going to say? "Gordon" wrote...

More understanding on linking table and make a grid query
Hello, I learnt from this forum that relationship of the query does not have to be the same as relation of the table. Can anyone explain to me more, whether all the table we have should setup relationship one to the others?. I found it that like the gender table for example, when I make relationship with the member table would stop my combo box. So neither relate it nor we put it on query would even better and my combo works. I need more explanation from all the experts in this forum. -- H. Frank Situmorang On Mon, 14 Jan 2008 22:34:00 -0800, Frank Situmorang <hfsitumo2001@yahoo...

make an AD "contact" appear in GAL?
i need my outlook users to see a persons name and email address when they click the "To" button on a new message but this person does not have a domain account. can i create them as a "contact" in AD and make them appear? or is there a better way to do this? You can create a contact in AD and add the e-mail address of the user. -- Greetings, Hans Sleurink MCSA +M , MCSE 2000 <jjd228@NOSPAMoptonline.net> wrote in message news:EDRgc.61876$_g4.9691579@news4.srv.hcvlny.cv.net... > i need my outlook users to see a persons name and email address when they > cli...

How do I make a backup file of my excel document?
I would like to make a backup file of some of my excel spreadsheets, onto my second hard drive. How do I do that? Stella, Simply choose the files, and use copy, select the destination folder, and select paste, all within Explorer. For future reference, you could use a macro that automatically saves files to two folders, along the lines of: Sub BUandSave() 'Saves the current file to a backup folder and its own folder Application.DisplayAlerts = False ActiveWorkbook.SaveCopyAs FileName:="D:\Excel Backup\" & _ ActiveWorkbook.Name ActiveW...

Make a text box expand or shrink based on size of the value
I am working on a report in design view. Is there a way to have a text box get longer or shrink according to the value? For example, one of the headers is "Operations" while another header is "Resource Integration." ***Since the text box has a blue fill, there will be empty space within the text box if I make it large enough to fit the longest word. Therefore, I want the text box to expand or shrink as necessary. Any input is appreciated. Thanks! Glen Set the 'Can Grow' property to Yes. -- Build a little, test a little. "*G...

Question about POSITION type variable
The MFC define POSITION as bellow: struct __POSITION { }; typedef __POSITION* POSITION; Q1: I think the purpose of define POSITION is just to use it as a pointer, why not define PVOID as POSITION? Is there any different in utility? Q2: How to use POSITION except in the MFC Collections ? wangyouhua wrote: >The MFC define POSITION as bellow: > > struct __POSITION { }; > typedef __POSITION* POSITION; > >Q1: >I think the purpose of define POSITION is just to use it as a pointer, why >not define PVOID as POSITION? Is there any different in utility? It's int...

How Do I Make My Calendar seen on my 3 network computers?
I would like to have the calendar I create on my desktop to be seen as well on my laptop and vice versa. They are connected wirelessly through a router. Also, can I make changes on one and have it change on the other? Thank you so much. unless you have outlook 2007, the easiest way is one of the utilities here: http://www.slipstick.com/outlook/share.htm -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-...

How to make a heatmap in Excel?
Dear All, I would like to construct a heatmap in Excel. In other words, a figure with two axes and each cell has a certain color based on the value for that cell (e.g., the higher the score, the darker the color). In example of such a figure can be found at: http://david.abcc.ncifcrf.gov/helps/2D_Introduction_files/classification_hea tmap.jpg Is this possible in Excel? Thanks in advance! You could use the cell colour as a conditional colour, that is using the data as the map itself.. Two problems, conditional formatting only supports 3 conditions, so you would have to use VBA event co...

Setting x axis scale to time with variable intervals
I want to chart observations made at random intervals throughout the day on an area chart. If i use x-y scatter, the x-axis spacing is correct (points are proportional to the time), but i can't get an area chart. If I use the area chart, the observations are all spaced equally along the x axis. Does anyone know how to make the x-axis plot time for normal charts? The XY Scatter chart is what I call a "normal" chart, because the X and Y axes are both numerical. That's my scientific background coming out. Other types of charts, such as column, line, and area, have a ...

Making a league table
Hi all, OK, I'm trying to make a league table of our branches within the company based on various criteria then put them in order of points 'scored', I wish to do this automatically. Am using the LARGE function along with INDEX/MATCH, which is fine however if two branches have the same score then in the resulting table both entries are given the same name. So if I have the following results in a worksheet; Branch A 60pts Branch B 80pts Branch C 60pts Branch D 20pts Branch E 60pts After the formulas have done their stuff I get something like this; Branch B 80pts Branch A 60pts...

Variable Save Filename
I had created a Invoice Template also with some form of autonumbering in a cell for Invoice Number e.g J12 will contain autogenerated value UBS1001. Upon opening a new invoice using File > New, and working on the invoice, how can I default the suggested filename in the SaveAs window to be "UBS1001" when I save the file instead of the default "Invoice1" Is a macro ok? Option Explicit Sub testme() Application.Dialogs(xlDialogSaveAs).Show _ Worksheets("sheet1").Range("j12").Value & ".xls" End Sub You could do tools|macr...

making a transfer show up in the budget
Hi all. I am running MS money 2006. How do I make a transfer show up in my budget? I have several liabilities and credit cards, and I would like to make a budget with the monthly amount owed to each creditor showing up in my budget. The MS Money 2006 standard program does not allow me, as far as I can tell, to make a monthly transfer to a credit card or liability show up in my budget, unless I make it a category. Any help with this is much appreciated. thanks See http://umpmfaq.info/faqdb.php?q=124 for the short answer. You may be more interested in "cash flow" than &qu...

Passing variables between a form and macro
Hi I have a working Excel VBA macro and would like to use a form for all the inputs. I have the form and the code behind the text/combo boxes etc. I just don't know how to call the form so that the data collected is passed to the variables in the main macro. I searched for this information but can only find info on creating the form rather than having it run with a macro. I'd appreciate any info, links etc. It would be great if you could point me to an example form with all the suurounding code, declarations etc. Can the form be used for the output of the macro? Thanks David ...

Making contacts appear in the global address list
Hi, I have SBS Pro including exchange 2003. I cannot figure out why I cannot get Contacts to appear in my global address list. I have a number of email addresses that would be really useful to everyone in the organisation (Courier email address etc). I have set up all of these addresses as Contacts in Active Directory under MYSERVER.local - Contacts - . I have also checked the filter for my Global Address List and it should include contacts. However none of these contacts will show. I have been struggling with this for some time now so the server has had plenty of time to replicate the chang...

receive-job
Hi, I want to build a scheduler with the Powersell job commands. So I start several vbs scripts and I need a possibility to check if the job still running or not. I Thought of using receive-job to check that and parse its output. Like this: $job = start-job {C:\Windows\SysWOW64\cscript D:\script.wsf $ID} $status = receive-job $job.id -Keep Unfortunately $status is always empty, so that I can't parse it. Also "write-output receive-job $job.id -Keep" does not work. When I do the same NOT in a .ps1 Script but directly on the Powershell it is working. What is m...

How do I make a check mark?
When I use the code for a checkmark (alt 80) in Excel, I get the letter P instead of the checkmark. In fact I tried several symbol shortcuts (alt + code) and got all letters. What am I missing? I use =char(252) (alt-0252) and a wingdings font. If you're using xl2002, you could find more checkmarks via Insert|symbol Chip Pearson has an addin that may help (if you're using xl2k or lower). http://www.cpearson.com/excel/download.htm (look for Symbolizer and make sure you get the correct version) kentrks wrote: > > When I use the code for a checkmark (alt 80) in Excel, I get ...

Making Excel act like a database.
I need some help on a common problem in our company. We have several clients that we have agreed to do some Excel 2003 spreadsheets for. The spreadsheets analyze our performance for them. These spreadsheets follow a very specific formatting that the clients have gotten use to and are unwilling to change. When we have to update the spreadsheets once a month, it can take all day to do the updating for each client because we are currently using copy and paste to get the data in the right cells. I'll explain more in a second, but what I am hoping to find out from this posting is alternate...

How do I make a graph of the frequency names come up in a column?
I have a column of several different names, most of which come up several times. I would like to make a graph of which names appear the most frequently. I haven't been able to figure out how to do this for the life of me. gziomek - Use either (1) a pivot table or (2) COUNTIF worksheet functions. For a pivot table, enter a label (e.g., Names) as the top cell of the column. Choose Data | Pivot Table ..., and for Layout use Names for both Row and Data entries. (I think the array-entered FREQUENCY worksheet function can be used only to count numerical values.) - Mike www.mikemid...

Make sheet tabs larger?
I have Excel 2000. Is it possible to make the tabs for each sheet larger, as in taller? Ed Only by making the worksheet name longer. -- HTH RP (remove nothere from the email address if mailing direct) "Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message news:OoFG6Qy2FHA.3744@TK2MSFTNGP10.phx.gbl... > I have Excel 2000. Is it possible to make the tabs for each sheet larger, > as in taller? > > Ed > > Hi Ed, Yes, you also make the scroll bars larger. WinStart button, Settings, Control Panel, Display, Appearance (tab), Item: Scrollbar c...

Add a field to a Make table on the fly
I have a DB with 5 tbl that all have like keys but different data. I need to be able to search the 5 tbls and return to the user all the find condition and allow them to select the one they want by dblclick. I want to add a field on the fly as I build the search query to id what tbl the record came from is there a simple way? the field can have a constant for each of the different tbl like tbl1, tbl2, etc... -- Les ...

make a report form for my family to show who paid and when
Hi lack of details :-) But you may have a look at Microsofts Template Gallery -- Regards Frank Kabel Frankfurt, Germany "teania" <teania@discussions.microsoft.com> schrieb im Newsbeitrag news:F2151689-1094-4AA2-B4C7-10507D4DD67A@microsoft.com... > If you want help with something specific, you'll need to provide some information about what you're doing, and where you're having trouble. If you need help getting started, there's lots of Excel information on the Microsoft web site: http://office.microsoft.com/en-ca/templates/CT011356681033.aspx and ...

how to make a cell available for "pull down seletion" ?
I want to do this: cell D2 PERSONAL SALARY cell D3 1000-2000 2001-3000 3001-4000 over 4000 that is, I want to make CELL D3 a pull down seletion , in order to avoid the users type numbers in it. How? Thanks! Martin Select cell D3 then Data | Validation - this allows you to restrict entries in a variety of ways, including a "List" which is what you want. You specify where the source list is (on the same sheet) and in this list you can type the values which are acceptable to your spreadsheet. Pete You can have the list on a separate...

Make a database available to only one user at at time?
I am not a networking person. I design Access databases. My client wants two people to be able to use an Access database on a server (that has Groups and users assigned) but that only one person at a time can open it. I have told them that the recommended solution is to split the database into front-end and back-end but their network person doesn't want me to do this(?)... I can lock down records in tables, but not the database. Can the network administrator set usage to a single person at a time? If you want only one to edit it at a time then *don't* split it. The 2...

global variable in MFC Regular DLL -pls urgent
Hi, I created a MFC Regular DLL and declare a variable int __declspec( dllexport ) g_iVar= 4; When i try to access these variable inthe application by importing g_iVar i am getting the value of g_iVar as 0 not 4. And i try to set the g_iVar to 10 in the application and try to access the value inside dll exported function i am getting it a 4 and not 10. Please help me out. Reny hi, Try setting the value of the g_iVar in the InitInstance() of the Dll and then use it. As far as the second case wherein you set the value of the g_iVar to 10 but the exported function of the dll reading i...

Can I erase part of a shape in Excel flowchart to make a "doorway.
i'm trying to update an evacuation plan. I need to create a "doorway" in an Excel flowchart shape - how can i erase part of the shape line? thanks Hi, Not sure why you want to use Excel for this kind of job, but you can place a shape over the line, make the right width, fill it in yr background colour (make sure it is opaque), and choose "no line". Your shape now appears to have a "hole" in one of the border lines. br, Henk "donnaatwork" wrote: > i'm trying to update an evacuation plan. I need to create a "doorway" in an &...