hola, disculpa por lo del post anterior...
es que quiero sumar las colomnas impares y las filas impares, ya me suma las filas pero no e podido sumar las columnas, este es el codigo que tengo
Public Class ssuma
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim tabla(5, 5) As String
With DataGridView1
.Columns.Add("", "")
.Columns.Add("", "")
.Columns.Add("", "")
.Columns.Add("", "")
.Columns.Add("", "")
.RowCount = 5
For i = 0 To 4
For j = 0 To 4
tabla(i, j) = InputBox("Digite un número")
.Item(i, j).Value = tabla(i, j)
Next
Next
End With
Dim fila1 As Integer = 0
Dim fila3 As Integer = 2
Dim fila5 As Integer = 4
Dim sumFila1 As Integer = (From cell As DataGridViewCell In DataGridView1.Rows.Item(fila1).Cells Select CInt(cell.Value)).Sum
Dim sumFila3 As Integer = (From cell As DataGridViewCell In DataGridView1.Rows.Item(fila3).Cells Select CInt(cell.Value)).Sum
Dim sumFila5 As Integer = (From cell As DataGridViewCell In DataGridView1.Rows.Item(fila5).Cells Select CInt(cell.Value)).Sum
Label1.Visible = True
Label1.Text = "La suma de los valores de la primer fila es de " & sumFila1
Label2.Visible = True
Label2.Text = "La suma de los valores de la tercera fila es de " & sumFila3
Label3.Visible = True
Label3.Text = "La suma de los valores de la quinta fila es de " & sumFila5
Dim Total As Single
Dim Col1 As Integer = Me.DataGridView1.CurrentCell.ColumnIndex
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Total += Val(row.Cells(Col1).Value)
Next
Me.Label4.Text = "la suma de los valores de la primera columnas es de " & Total.ToString
Dim Total1 As Single
Dim Col3 As Integer = Me.DataGridView1.CurrentCell.ColumnIndex
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Total1 += Val(row.Cells(Col3).Value)
Next
Me.Label5.Text = Total.ToString
Dim Total2 As Single
Dim Col5 As Integer = Me.DataGridView1.CurrentCell.ColumnIndex
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Total2 += Val(row.Cells(Col5).Value)
Next
Me.Label6.Text = Total.ToString
End Sub
Private Sub VOLVERALMENUINICIALToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VOLVERALMENUINICIALToolStripMenuItem.Click
Me.Close()
mnprincipal.Show()
End Sub
Private Sub SALIRToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALIRToolStripMenuItem.Click
MsgBox("desea abandonar el programa", 36)
MsgBox("esta seguro de salir", 36)
MsgBox("hasta pronto")
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
DataGridView1.Columns.Clear()
DataGridView1.Rows.Clear()
Label1.Text = ""
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
Label5.Text = ""
Label6.Text = ""
End Sub
End Class