lunes, 30 de septiembre de 2019

martes, 24 de septiembre de 2019

Cargar combobox en datagrid

Public Sub tipo_dato()
        For i As Integer = 0 To dg_variables.Rows.Count - 1 ' filas
            Dim dg_cb As New DataGridViewComboBoxCell
            dg_cb.Items.Add("Hola1")
            dg_cb.Items.Add("Hola2")
            dg_cb.Items.Add("Hola3")
            dg_variables.Item(col_tipo, i) = dg_cb
        Next
    End Sub

validar si un string es número

Dim n As Integer
Dim numero As Boolean = Integer.TryParse("123", n)


Public Function get_validar_numero(ByVal val As String) As Boolean
        Dim n As Integer
        Return Integer.TryParse(val, n)
    End Function

jueves, 12 de septiembre de 2019

buscar dato en archivo

Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click


        'Dim archivo() As String = File.ReadAllLines("")
        Dim archivo() As String = File.ReadAllLines("")

        Dim fila As Integer = tb_fila.Text.Trim
        Dim columna As Integer = tb_columna.Text.Trim
        Dim largo As Integer = tb_largo.Text.Trim


        Dim dato As String = ""


        'If fila > archivo.Length Then
        '    Exit Sub
        'End If


        For i As Integer = 0 To archivo.Length - 1
            If i = fila - 1 Then
                Dim linea() As Char = archivo(i)
                If linea.Length = 0 Then
                    MessageBox.Show("Línea vacía")
                    Exit Sub
                Else
                    For j As Integer = 0 To linea.Length - 1
                        If j = columna - 1 Then
                            'MessageBox.Show(linea(j))

                            Dim n As Integer = j + largo - 1
                            If n >= linea.Length Then
                                MessageBox.Show("No se puede obtener el dato")
                                Exit Sub
                            Else
                                For k As Integer = j To n
                                    dato += linea(k)
                                Next
                                MessageBox.Show(dato)
                                Return
                            End If
                        End If
                    Next
                End If
            End If
        Next

        Dim pause1 As String = ""

    End Sub

viernes, 6 de septiembre de 2019

Eliminar fila datagridview

 If dg_view.Rows.Count > 0 Then
            dg_view.Rows.Remove(dg_variables.CurrentRow)
        End If