473,466 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

1 New Member
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 1164

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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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...
1
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.