473,320 Members | 1,831 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.

How to perform addition on each of the rows and columns and diagonally of the arra

1
The Random generator works fine. What I have a problem with is adding the rows and columns.
Array
0,0 0,1 0,2 = row total
1,0 1,1 1,2 = row total
2,0 2,1 2,2 = row total
= = =
col total coltotal col total
also add 0,0 1,1 2,2

Expand|Select|Wrap|Line Numbers
  1. Private Sub BtnFillArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFillArray.Click
  2.  
  3.         Dim Row As Integer
  4.         Dim Col As Integer
  5.         Dim Number As Integer
  6.  
  7.         Number = RandomNumber.Next(RandomNumberLimit)
  8.         For Row = 0 To 2
  9.             For Col = 0 To 2
  10.                 TwoDim(Row, Col) = Number
  11.  
  12.                 Number += 1
  13.             Next Col
  14.         Next Row
  15.  
  16.         Lbl3x3ArrCell00.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  17.         Lbl3x3ArrCell01.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  18.         Lbl3x3ArrCell02.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  19.         Lbl3x3ArrCell10.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  20.         Lbl3x3ArrCell11.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  21.         Lbl3x3ArrCell12.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  22.         Lbl3x3ArrCell20.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  23.         Lbl3x3ArrCell21.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  24.         Lbl3x3ArrCell22.Text = CStr(RandomNumber.Next(RandomNumberLimit))
  25.     LblGBRowR1r0.Text = ""   (holds results of 0,0 0,1 0,2)
  26.     LblGBRowR1r1.Text = ""   (holds results of 1,0 1,1 1,2)
  27.     LblGBRowR1r2.Text = ""   (holds results of 2,0 2,1 2,2)
  28.  
  29.     LblGBColC1c0.Text = ""   (holds results of 0,0 1,0 2,0)
  30.     LblGBColC1c1.Text = ""   (holds results of 0,1 1,1 2,1)
  31.     LblGBColC1c2.Text = ""   (holds results of 0,2 2,1 2,2)
  32.  
  33.     LblGBDiaL.Text = ""      (holds results of 0,0 1,1 2,2)
  34.     LblGBDiaR.Text = ""      (holds results of 02 1,1 2,0)
  35.  End Sub
  36.  
  37. Tried this but results were faulty
  38.   Private Sub BtnCF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCF.Click
  39. 'LblGBRowR1r0.Text = Convert.ToString(CInt(((TwoDim(0, 2) + TwoDim(0, 1) + TwoDim(0, 0)))))
  40.     'LblGBRowR1r1.Text = Convert.ToString(CInt(((TwoDim(1, 0) + TwoDim(1, 1) + TwoDim(1, 2)))))
  41.     'LblGBRowR1r2.Text = Convert.ToString(CInt(((TwoDim(2, 0) + TwoDim(2, 1) + TwoDim(2, 2)))))
  42.     'LblGBColC1c0.Text = Convert.ToString(CInt(((TwoDim(0, 0) + TwoDim(1, 0) + TwoDim(2, 0)))))
  43.     'LblGBColC1c1.Text = Convert.ToString(CInt(((TwoDim(0, 1) + TwoDim(1, 1) + TwoDim(2, 1)))))
  44.     'LblGBColC1c2.Text = Convert.ToString(CInt(((TwoDim(0, 2) + TwoDim(1, 2) + TwoDim(2, 2)))))
  45.     'LblGBDiaL.Text = Convert.ToString(CInt(((TwoDim(0, 0) + TwoDim(1, 1) + TwoDim(2, 2)))))
  46.     'LblGBDiaR.Text = Convert.ToString(CInt(((TwoDim(0, 2) + TwoDim(1, 1) + TwoDim(2, 0)))))
  47.     'End Sub
Just need a simple method to add Thanks
May 23 '12 #1
0 1179

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

Similar topics

2
by: J055 | last post by:
Hi I've been looking into different ways of formatting columns/rows in the GridView control. I realize now, I think, that once the datasource is bound to the control the original column type...
1
by: pinkyrose | last post by:
Hi there, i need some help in accessing a the ith row in a NxM array in vba. More specifically i have an NxM array called prices and i want to find the average of each row ,as well as the mean...
0
by: yoav.sagi | last post by:
hi, i am Inheriting from TableLayoutPane with a designer that inherits from ParentControlDesigner ..i would like to allow the user to resize the columns and rows ..All rows and columns SizeType =...
4
by: selvamariappan | last post by:
Hi all , how to display various color for rows in datagrid in vb.net 2005, Not a Alternate colors, Thanks and regards selvamariappan.c
3
by: aashishn86 | last post by:
i am using this function to add rows dynamically function addRow() { var tbl = document.getElementById('applications'); var lastRow = tbl.rows.length; // if there's no header row in...
6
by: viki1967 | last post by:
Hi all. I need your help. I realize this script and I do not know where to begin: 1) A simple grid rows / columns. 2) The first column contain an input type = "checkbox" 3) When select...
3
by: ronakinuk | last post by:
how can i unhide rows/columns in excel 2007
3
by: frj1001 | last post by:
Hi i am new to c sharp. i am building a simple calculator with a text box and few buttons. i need to store values entered into the text box from string to char array so that i can check for the '+'...
1
by: nawedita | last post by:
Hi everyone how i add and delete rows,and columns(textbox,dropdown) dynamically onclick button and store data in database with insert,update,delete record.that support all browsers.Because i am...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.