473,508 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to calculate cell data in DataGridView VB

1 New Member
Sir plz tell me how to calculate all rows data . i mean how i change this code into for loop .
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.  
  3. Dim A As Double
  4. Dim B As Double
  5. Dim C As Double
  6. Dim D As Double
  7. Dim Z As Double
  8.  
  9. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10.  
  11. A = Double.Parse(DataGridView1.Item(0, 0).Value)
  12. B = Double.Parse(DataGridView1.Item(1, 0).Value)
  13. C = Double.Parse(DataGridView1.Item(2, 0).Value)
  14. D = Double.Parse(DataGridView1.Item(3, 0).Value)
  15.  
  16. Z = A + B + C + D
  17.  
  18. DataGridView1.Item(4, 0).Value = Z.ToString
  19.  
  20. End Sub
  21. End Class
Sep 19 '14 #1
1 1440
twinnyfo
3,653 Recognized Expert Moderator Specialist
Asad,

I would presume it would be easily done by declaring a variable to account for your row number, and increment that variable by one. Check each row for data first, then, if there is data, calculate the other variables.
Sep 22 '14 #2

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

Similar topics

1
4877
by: Niche | last post by:
I am new to VB.net, I know how to make command buttons and text boxes on a VB form. I need help with writing the code to ope and Excel 97 spreadsheet and place a cell data (A1) into my VB.net...
7
1855
by: JohnSmith90 | last post by:
I want to highlight the entire cell data for all rows of a particular column in a data grid. I do not want to fill the back ground color of the cell. How to do that in a data grid? <span...
2
1254
by: Bsr | last post by:
Hi, Please tell the solutions for the following queries. 1. How to read the data from Excel file. 2. How to get the cell data in to the varaible from existed Excel file. Its very argent...
2
2105
by: mvenkatesan | last post by:
Hi guys I am developing a project, use datagridview the datas are stored arraylist I am bind the data using datatable & databind the datagridview data displayed perfect. But i am set one...
3
1823
nirmalsingh
by: nirmalsingh | last post by:
hai all, How to place a control dynamically in cell of datagridview control?in run time. i am using C#.net(Windows application) thanx in advance with Cheers Nirmal
0
2327
by: krishnaneeraja | last post by:
Hi, I am working on windows application. In that i want to place name in bold,address,url in link in one cell using datagridview. please help me.
3
2511
by: KrishnaSarala | last post by:
Hi All IT developer and C# expert please help me urgent. I'm working on a project of Bakery Management. I'hd shown the room booked in hotel in Datagridveiw Control. My client require the cell color...
2
1909
by: Ghayas | last post by:
Hello, its quite strange that i m itearing a gridview to get some of its cell data but its not show me data, i m doing like this for i=0 to GView.rows.count-1 ...
5
5901
by: Big P | last post by:
Hello, I would like to calculate cells in DataGridView ( VB Express) My datagridview1 looks something like this. --------------------------------------… ...
0
7391
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
7054
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
7501
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...
0
5633
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,...
1
5056
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
4713
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
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.