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

how to Add column cell value to previos cell value and get result

this my code
iwant to add column cellvalue in datagridview to previouse number of cells user insert
the summ variable always equal zero


any help
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         year = TextBox1.Text
  3.         month = TextBox2.Text
  4.         noofmonths = TextBox3.Text
  5.         Dim summ As String
  6.         summ = 0
  7.         Dim rowindex As Integer
  8.  
  9.  
  10.  
  11.         For Each row As DataGridViewRow In DataGridView1.Rows
  12.             If row.Cells.Item(1).Value = TextBox1.Text Then
  13.                 If row.Cells.Item(2).Value = TextBox2.Text Then
  14.                     rowindex = row.Index
  15.  
  16.  
  17.  
  18.  
  19.                     For i As Integer = rowindex To noofmonths And i <> 0
  20.  
  21.                         summ = row.Cells.Item(3).Value + summ
  22.  
  23.  
  24.                         rowindex = row.Index - 1
  25.  
  26.                         i = i - 1
  27.  
  28.  
  29.  
  30.  
  31.                     Next
  32.                     summ = summ / noofmonths.ToString
  33.  
  34.                     rowindex = rowindex + noofmonths
  35.                     Dim actie As String = row.Cells(3).Value.ToString()
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.                     row.Cells(4).Value = summ
  50.  
  51.                     MsgBox(summ)
  52.  
  53.                 Else
  54.  
  55.                     MsgBox("Item not found")
  56.  
  57.                 End If
  58.             End If
  59.  
  60.  
  61.         Next
May 2 '15 #1
0 1162

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

Similar topics

9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
40
by: Zach | last post by:
Can someone please explain what this means and illustrate the difference with some code. Thanks, Zach
0
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL,...
3
by: bharathi228 | last post by:
hi, iam doing one asp.net application in gridview i have 3 columns. the first two column values are coming from database. the third column is template field.here i have one...
16
by: tarunkhatri | last post by:
Hi. I have a javascript function to change the value of the cell on chnage event of a dropdown list.My code is workin but the problem is that the value of the cell is chaning but not respective to...
10
by: Vivekneo | last post by:
Hi I am very new to web programming, trying to achieve a task, I have a form with 3 dropdown box and a text field(which is readonly). My problem now is, after selecting the above 3 dropdown boxes,...
2
by: shalskedar | last post by:
In my Application,I need to split the cell value in such a way that the each splitted values is stored as different record... for ex-If the value in the cell A1 is (20,43,15) then it should be...
3
by: uxcrh | last post by:
Hello All, I have a simple data-table being sourced from an Oracle DB. There is a column whereas each cell contains only one character - "R","Y", or "N". The logic is focused on the correct...
1
by: akmughal | last post by:
I want to append "0" along with cell value if there is no "0" in beaning of cell value. Range of cells are S3:S100 I tried the following logic but it does not work. For Each cell In If...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.