473,659 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2-dimensional array


my 2-dimensional array, is given me the following error message,
'For' loop control variable cannot be of type '1-dimensional array of
String'.

has anybody got a tip on what I have incorrect,

Thanks
Nov 20 '05 #1
6 1622
"portroe" <bo*@sleigh.com > schrieb

my 2-dimensional array, is given me the following error message,
'For' loop control variable cannot be of type '1-dimensional array
of
String'.

has anybody got a tip on what I have incorrect,

Please post Code.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* portroe <bo*@sleigh.com > scripsit:
my 2-dimensional array, is given me the following error message,

'For' loop control variable cannot be of type '1-dimensional array
of String'.

has anybody got a tip on what I have incorrect,


You will have to use 2 nested loops to loop though the array.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
'thanks
'Declaration of variables and arrays as public
Public AmountclubYear( 4, 0) As Decimal
Public club(4) As Integer
Public Year() As Integer
Public InputStartingYe ar As Integer
Public InputFinalYear As Integer
Public x As Integer

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'store the name of each club
club(0) = "r54000"
club(1) = "r54001"
club(2) = "r54002"
club(3) = "r54003"
club(4) = "r54004"

'user enters start and final year,

InputStartingYe ar = InputBox("Pleas e enter the starting year.")
InputFinalYear = InputBox("Pleas e enter the final year.")

'Program to calculate the number of years
x = InputStartingYe ar - InputFinalYear

'redim
ReDim Year(x)
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'the user will be prompted by input boxes for cost

For club = 0 To 4
For Year = 0 To x
AmountclubYear( club, Year) = _
CDec(InputBox(" Enter the cost incurred for club ",
club, " and year ", Year))
Next Year
Next club
End Sub
End Class

Armin Zingler wrote:
"portroe" <bo*@sleigh.com > schrieb
my 2-dimensional array, is given me the following error message,
'For' loop control variable cannot be of type '1-dimensional array
of
String'.

has anybody got a tip on what I have incorrect,


Please post Code.


Nov 20 '05 #4
"portroe" <bo*@sleigh.com > schrieb


[code]


Please enable Option Strict first. Add the line

Option Strict On

add the top of the source code file, or enabled it in the project
properties. (menu project->properties: general properties->build: Option
Strict On)

After that, fix the obviuos bugs, then I can have a look at it again.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister. org/news/learn2quote.htm l

Nov 20 '05 #5
On Tue, 16 Dec 2003 11:37:22 +0100, portroe wrote:

You need to use simple variables in a for next loop.
Public x As Integer For club = 0 To 4
For Year = 0 To x
AmountclubYear( club, Year) = _
CDec(InputBox(" ...")
Next Year
Next club


The problem is that you're using array variables (club and Year) in the for
loop instead of simple variables.

Use something like this instead:

Public c As Integer
Public y As Integer

For c = 0 to 4
For y = 0 to x
AmountclubYear( c,y) = CDec(InputBox(. ...))
Next
Next

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #6
"Chris Dunaway" <dunawayc@_lunc hmeat_sbcglobal .net> schrieb

You need to use simple variables in a for next loop.


No, not necessarily. This works:

Dim x(0, 0) As Integer
For x(0, 0) = 0 To 15
Debug.WriteLine (x(0, 0))
Next

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2779
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
575
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a print_r cmd any suggestions would be great. Thanks much Todd //avShed array Array ( => Array ( => 1 => 08:00 ) => Array ( => 1 => 08:05 ) => Array ( => 1 => 08:10 ) => Array ( => 1 => 08:15 ) => Array ( => 1 => 08:20 ) => Array...
15
5178
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
3474
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array( "name", "title", "reports to user id", "start date in the format: mm/dd/yyyy" ) ); How can I display this hierarchy in simple nested <li> tags in the most
12
55548
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are also removed) So far I have (val is value, ar is array, returns new array):
8
10218
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
7
1707
by: ffld | last post by:
Greetings all i am having a horrible time trying to pass a 2 dimensional array of doubles to a function... basically a watered down version of my code looks like: void t1(double a); int main() { double d; d = 2.3;
11
1620
by: efialtis | last post by:
Hi to all, I am creating a program which plays a game. The game is played on a NxN square board. In every position of the board we may have a ball or not. Take for example the following 5x5 board ( x : ball, o : empty space). x x o o x x o o o o o o x x o
3
2180
by: j-in-uk | last post by:
Hi, I have a table with 2 columns and a one dimensional string array. I need to copy the string array to the table but I think I have to convert my string array to a 2dimensional array first with an incremental id inorder to add to table. any suggestions how to? thanks DataTable dtContinent = ds.Tables.Add("Continent"); DataColumn dtContinent_ID = dtContinent.Columns.Add("ID", typeof(int)); DataColumn dtContinent_Name =...
8
1555
by: Relative0 | last post by:
I have a rather elusive problem and have spent some amount of time on it, I would very kindly appreciate it if anyone could give me insight on how to solve this problem. I tried to include what I thought was necessary without overkilling it. Basically it seems as if a "lattice" is being created. the tgrundgitter(~,~,~,~) is declared in another header file. as well as heightfct(~,~). I don't understand what is going on in the...
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.