473,395 Members | 2,222 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,395 software developers and data experts.

How to calculate cell data in DataGridView VB

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 1436
twinnyfo
3,653 Expert Mod 2GB
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
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
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
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
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
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
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
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
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
by: Big P | last post by:
Hello, I would like to calculate cells in DataGridView ( VB Express) My datagridview1 looks something like this. --------------------------------------… ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.