0% found this document useful (0 votes)
51 views2 pages

Dim As String Dim As Integer Me For Each As in Me Next

The document provides code examples for: 1) Looping through rows and cells of a datagrid to retrieve cell values. 2) Creating a class with a boolean property and adding objects of that class to a list that is then bound to a datagrid. 3) Clicking a button that inserts data from textboxes and datetimepickers into a MySQL database table.

Uploaded by

fabyjs001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views2 pages

Dim As String Dim As Integer Me For Each As in Me Next

The document provides code examples for: 1) Looping through rows and cells of a datagrid to retrieve cell values. 2) Creating a class with a boolean property and adding objects of that class to a list that is then bound to a datagrid. 3) Clicking a button that inserts data from textboxes and datetimepickers into a MySQL database table.

Uploaded by

fabyjs001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

'Recorrer los valores de una Columna Dim Valor As String Dim Col As Integer = Me.DataGridView1.CurrentCell.

ColumnIndex For Each row As DataGridViewRow In Me.DataGridView1.Rows Valor = row.Cells(Col).Value Next


Para recorrer las filas de un datagrid el cdigo seria algo asi: for(int i=0; i<DataGrid1.Items.Count;i++) { for(int j=0; j<DataGrid1.Items[i].Cells.Count; j++) { string valor = DataGrid1.Items[i].Cells[j].Text; } }

Dim i As Integer For i = 0 To selectedRowCount - 1 'falta aca Next Dim x As Integer For x = 0 To DataGridView5.Rows.Count Dim sel = DataGridView5.Rows(x).Cells(0).Value() MsgBox("valor de la celda: " & sel) Next

Public Class Form1 Class persona Private xEstado As Boolean Public Property Estado() As Boolean Get Return xEstado End Get Set(ByVal value As Boolean) xEstado = value End Set End Property End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim xPer1 As New persona Dim xPer2 As New persona xPer1.Estado = True xPer2.Estado = False Dim xPersonas As New List(Of persona) xPersonas.Add(xPer1) xPersonas.Add(xPer2) DataGridView1.DataSource = xPersonas For index As Integer = 0 To DataGridView1.Rows.Count - 1 Dim xValor As String = DataGridView1.Rows(index).Cells(0).Value.ToString() MessageBox.Show("El valor es: " & xValor) Next End Sub End Class

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Dim conn As New MySqlConnection Dim myCommand As New MySqlCommand conn.ConnectionString = myConnString myCommand.Connection = conn myCommand.CommandText = ("INSERT INTO tallerbd.serv_preventivo (unidad, engrasado, motor, diferencial, transmision, comentario, quien) values ('" & TextBox2.Text & "', '" & Format(DateTimePicker2.Value, "yyyy/MM/dd") & "', '" & Format(DateTimePicker2.Value, "yyyy/MM/dd") & "', '" & Format(DateTimePicker2.Value, "yyyy/MM/dd") & "', '" & Format(DateTimePicker2.Value, "yyyy/MM/dd") & "', '" & TextBox15.Text & "')") Try conn.Open() myCommand.ExecuteNonQuery() MsgBox("GUARDADO") Catch myerror As MySqlException MsgBox("Error al actualizar la base de datos: " & myerror.Message) End Try End Sub

You might also like