443,572 Members | 1,439 Online Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

# A Question on Arrays.

 P: n/a Hello , I am kinda new to VB 6.0. Is the line of code Private strCol(62, 2) As String declares a three dimensional array? Because in the code it is being used as strCol(1,0) = "x" strCol(2,0 )= "x" strcol(3,0) = "x" .... strCol(1,1) = "x" strCol(2,1) = "x" .... strCol(1,2) = "x" strCol(2,2) = "x" strCol(3,2) = "x" Please take a moment to explain. thanks -L Nov 13 '06 #1
9 Replies

 P: n/a I am kinda new to VB 6.0. You must be new to this newsgroup to - it's a .NET (vb2002, vb2003, and vb2005) newgroup not a VB classic (vb1 - 6) newsgroup. You should post VB classic questions to the microsoft.public.vb ng. But since the question does apply to vb.Net I'll go ahead and answer. The code you provided declares a two dimensional array. 2 dimensional arrays are sort of like a standard database table. In this case it would be a 62 by 2 table (which means it has 124 cells). So when you do strCol(1,2) = "x" you are just putting the string "x" into cell (1, 2). Does that make more sense? Thanks, Seth Rowe Learner wrote: Hello , I am kinda new to VB 6.0. Is the line of code Private strCol(62, 2) As String declares a three dimensional array? Because in the code it is being used as strCol(1,0) = "x" strCol(2,0 )= "x" strcol(3,0) = "x" ... strCol(1,1) = "x" strCol(2,1) = "x" ... strCol(1,2) = "x" strCol(2,2) = "x" strCol(3,2) = "x" Please take a moment to explain. thanks -L Nov 13 '06 #2

 P: n/a Hello rowe, Thanks for answering my question. I understand your explanation. But the thing I don't understand is 1st set with '0' strCol(1,0) strCol(2,0) .... strCol(62,0) 2nd set with '1' strCol(1,1) strCol(2,1) ..... strCol(62,1) 3rd set with '2' strCor(1,2) strCol(2,2) .... strCol(62,2) is not it 62X3 = 186 as it starts with '0' ? Please take one more minute to clarify. thanks -L rowe_newsgroups wrote: I am kinda new to VB 6.0. You must be new to this newsgroup to - it's a .NET (vb2002, vb2003, and vb2005) newgroup not a VB classic (vb1 - 6) newsgroup. You should post VB classic questions to the microsoft.public.vb ng. But since the question does apply to vb.Net I'll go ahead and answer. The code you provided declares a two dimensional array. 2 dimensional arrays are sort of like a standard database table. In this case it would be a 62 by 2 table (which means it has 124 cells). So when you do strCol(1,2) = "x" you are just putting the string "x" into cell (1, 2). Does that make more sense? Thanks, Seth Rowe Learner wrote: Hello , I am kinda new to VB 6.0. Is the line of code Private strCol(62, 2) As String declares a three dimensional array? Because in the code it is being used as strCol(1,0) = "x" strCol(2,0 )= "x" strcol(3,0) = "x" ... strCol(1,1) = "x" strCol(2,1) = "x" ... strCol(1,2) = "x" strCol(2,2) = "x" strCol(3,2) = "x" Please take a moment to explain. thanks -L Nov 13 '06 #3

 P: n/a Hello rowe, Thanks for answering my question. I understand your explanation. But the thing I don't understand is 1st set with '0' strCol(1,0) strCol(2,0) .... strCol(62,0) 2nd set with '1' strCol(1,1) strCol(2,1) ..... strCol(62,1) 3rd set with '2' strCor(1,2) strCol(2,2) .... strCol(62,2) is not it 62X3 = 186 as it starts with '0' ? Please take one more minute to clarify. thanks -L rowe_newsgroups wrote: I am kinda new to VB 6.0. You must be new to this newsgroup to - it's a .NET (vb2002, vb2003, and vb2005) newgroup not a VB classic (vb1 - 6) newsgroup. You should post VB classic questions to the microsoft.public.vb ng. But since the question does apply to vb.Net I'll go ahead and answer. The code you provided declares a two dimensional array. 2 dimensional arrays are sort of like a standard database table. In this case it would be a 62 by 2 table (which means it has 124 cells). So when you do strCol(1,2) = "x" you are just putting the string "x" into cell (1, 2). Does that make more sense? Thanks, Seth Rowe Learner wrote: Hello , I am kinda new to VB 6.0. Is the line of code Private strCol(62, 2) As String declares a three dimensional array? Because in the code it is being used as strCol(1,0) = "x" strCol(2,0 )= "x" strcol(3,0) = "x" ... strCol(1,1) = "x" strCol(2,1) = "x" ... strCol(1,2) = "x" strCol(2,2) = "x" strCol(3,2) = "x" Please take a moment to explain. thanks -L Nov 13 '06 #4

 P: n/a Oops, I made a mistake there - it should be an array sized 63 x 3 (189 cells) - Arrays where revamped in .NET so that dim str(4) as string would declare an array with four members (str(0), str(1), str(2) and str(3)) That same statement in vb classic declares an array with 5 members (str(0), str(1), str(2), str(3) and str(4)). This is one of the many things that changed in .Net, and is a terrific example of why the two newgroups are seperate from each other. If this same question was posted in the vb classic ng they would have used the vb6 definition of an array and correctly answered your question. Thanks, Seth Rowe Learner wrote: Hello rowe, Thanks for answering my question. I understand your explanation. But the thing I don't understand is 1st set with '0' strCol(1,0) strCol(2,0) ... strCol(62,0) 2nd set with '1' strCol(1,1) strCol(2,1) .... strCol(62,1) 3rd set with '2' strCor(1,2) strCol(2,2) ... strCol(62,2) is not it 62X3 = 186 as it starts with '0' ? Please take one more minute to clarify. thanks -L rowe_newsgroups wrote: I am kinda new to VB 6.0. You must be new to this newsgroup to - it's a .NET (vb2002, vb2003, and vb2005) newgroup not a VB classic (vb1 - 6) newsgroup. You should post VB classic questions to the microsoft.public.vb ng. But since the question does apply to vb.Net I'll go ahead and answer. The code you provided declares a two dimensional array. 2 dimensional arrays are sort of like a standard database table. In this case it would be a 62 by 2 table (which means it has 124 cells). So when you do strCol(1,2) = "x" you are just putting the string "x" into cell (1, 2). Does that make more sense? Thanks, Seth Rowe Learner wrote: Hello , I am kinda new to VB 6.0. Is the line of code Private strCol(62, 2) As String declares a three dimensional array? > Because in the code it is being used as strCol(1,0) = "x" strCol(2,0 )= "x" strcol(3,0) = "x" ... strCol(1,1) = "x" strCol(2,1) = "x" ... strCol(1,2) = "x" strCol(2,2) = "x" strCol(3,2) = "x" > > Please take a moment to explain. > > thanks -L Nov 13 '06 #5

 P: n/a This is a rather unfortunate aspect of arrays: whether they are Zero or One based. For example, if I declare a simple array as follows: Dim myIntegers (1), you might think I'm declaring one integer, but no, I'm declaring 2! myIntegers (0) and myIntegers (1). The dimension in brackets represents the upper inclusive bound on the set 0..1. Now, your declaration, (62, 2), means you have 3 rows ( 0..2 ) with 63 columns ( 0..62 ), so in total you have 63 * 3 "cells" (189). "Learner"

 P: n/a rowe_newsgroups wrote: Oops, I made a mistake there - it should be an array sized 63 x 3 (189 cells) - Arrays where revamped in .NET so that dim str(4) as string would declare an array with four members (str(0), str(1), str(2) and That is incorrect, the VB.Net behavior is the same as VB6. Dim str(4) declares an array with 5 members. 0, 1, 2, 3, 4. In the beginning, VB.Net worked the way C# did, with the number indicating the number of members, but they changed it back to the VB6 way because there were many complaints that it broke compatibility with VB6 code. Nov 13 '06 #7

 P: n/a In the beginning, VB.Net worked the way C# did, with the number indicating the number of members, but they changed it back to the VB6 way because there were many complaints that it broke compatibility with VB6 code. Thanks for the correction! Which version switched this back? Thanks, Seth Rowe Chris Dunaway wrote: rowe_newsgroups wrote: Oops, I made a mistake there - it should be an array sized 63 x 3 (189 cells) - Arrays where revamped in .NET so that dim str(4) as string would declare an array with four members (str(0), str(1), str(2) and That is incorrect, the VB.Net behavior is the same as VB6. Dim str(4) declares an array with 5 members. 0, 1, 2, 3, 4. In the beginning, VB.Net worked the way C# did, with the number indicating the number of members, but they changed it back to the VB6 way because there were many complaints that it broke compatibility with VB6 code. Nov 13 '06 #8

 P: n/a rowe_newsgroups wrote: In the beginning, VB.Net worked the way C# did, with the number indicating the number of members, but they changed it back to the VB6 way because there were many complaints that it broke compatibility with VB6 code. Thanks for the correction! Which version switched this back? Version 1.0. The new syntax never made it out of beta IIRC. Nov 13 '06 #9

 P: n/a That'll teach me to believe an article about "whats new in vb.net" that was written during beta testing :-) Thanks, Seth Rowe Chris Dunaway wrote: rowe_newsgroups wrote: In the beginning, VB.Net worked the way C# did, with the number indicating the number of members, but they changed it back to the VB6 way because there were many complaints that it broke compatibility with VB6 code. Thanks for the correction! Which version switched this back? Version 1.0. The new syntax never made it out of beta IIRC. Nov 13 '06 #10

### This discussion thread is closed

Replies have been disabled for this discussion. 