miércoles, 12 de junio de 2019

For each array

For Each c As String In New String() {"1", "2", "3", "4"}
                MessageBox.Show(c)
            Next

martes, 11 de junio de 2019

borrar múltiples filas datagridview


Dim selectedCellCount As Integer = dgv_nodos_sii.SelectedRows.Count
Dim j As DataGridViewSelectedRowCollection = dgv_nodos_sii.SelectedRows


Seleccionar filas de mayor a menor

For Each row As DataGridViewRow In dgv_nodos_sii.SelectedRows
           MessageBox.Show(row.Index)
Next


Seleccionar filas de menor a mayor

For Each row As DataGridViewRow In dgv_nodos_sii.SelectedRows.Cast(Of DataGridViewRow).OrderBy(Function(dgvr) dgvr.Index)
               MessageBox.Show(row.Index)
Next

fuente

viernes, 7 de junio de 2019

reglas xml

fuente

seleccionar item automaticamente



listbox.SetSelected(1,True)


fuente

ToolTip listbox

Private Sub lb_dte_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lb_dte.MouseMove


        Dim i As Integer = lb_dte.IndexFromPoint(e.Location)

        If i > -1 Then
            Dim tip As String = lb_dte.Items(i).ToString

            'Dim tipw As ToolTip = Nothing

            If tip = 33 Then
                tip = "Factura electrónica"
            ElseIf tip = 34 Then
                tip = "Factura exenta"
            ElseIf tip = 39 Then
                tip = "Boleta electrónica"
            ElseIf tip = 41 Then
                tip = "Boleta exenta"
            ElseIf tip = 43 Then
            ElseIf tip = 46 Then

            End If

            If (ToolTip1.GetToolTip(lb_dte) IsNot tip) Then
                ToolTip1.SetToolTip(lb_dte, tip)
            End If
        End If
    End Sub

jueves, 6 de junio de 2019

ordenar listbox

Dim arr() As Integer = New Integer(lb_dte_activo.Items.Count - 1) {}
            Dim i As Integer = 0

            For Each elem In lb_dte_activo.Items
                arr(i) = elem
                i += 1
            Next
            Array.Sort(arr)
            'lb_dte_activo.Sorted = False
            lb_dte_activo.Items.Clear()
            lb_dte_activo.Items.AddRange(arr.Cast(Of Object).ToArray())

fuente

contar elementos de un nodo

 Dim i As Integer = doc.GetElementsByTagName(nodo)(0).ChildNodes.Count

miércoles, 5 de junio de 2019

crear setgesys

 Private Sub btn_envio_xml_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_envio_xml.Click

        Dim lineas As New ArrayList


        Dim txt() As String = File.ReadAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK\DTE33F10331.xml", Encoding.GetEncoding("ISO-8859-1"))
        lineas.AddRange(txt)

        lineas.Insert(1, "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">")
        lineas.Insert(2, "  <Extras>")
        lineas.Insert(3, "  </Extras>")
        lineas.Add("</SetGESYS>")
        'txt(1) = "  <EnvioDTE xmlns=""http://www.sii.cl/SiiDte"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sii.cl/SiiDte EnvioDTE_v10.xsd"" version=""1.0"">"

        'txt(1) = "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">"

        'File.WriteAllText("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "gesys.xml2", , System.Text.Encoding.GetEncoding("ISO-8859-1")) ' sólo prueba

        File.WriteAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "archivo.xml", lineas.Cast(Of String).ToArray, System.Text.Encoding.GetEncoding("ISO-8859-1"))

    End Sub

cargar nodos xml

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim doc As New XmlDocument
        doc.Load("archivo.xml")
        Dim xml_nodos As XmlNode = doc.GetElementsByTagName("IdDoc")(0)

        Dim array() As String = Nothing


        For Each elem As XmlNode In xml_nodos
            array = {"", False, False, False, False, False}

            array(0) = elem.Name
            Dim dte() As Integer = elem.InnerXml.Split(",").Select(Function(x) Int32.Parse(x)).ToArray

            For Each tipo_dte In dte
                Select Case tipo_dte
                    Case 33
                        array(1) = True
                    Case 34
                        array(2) = True
                    Case 39
                        array(3) = True
                    Case 56
                        array(4) = True
                    Case 61
                        array(5) = True
                End Select
            Next
            DataGridView1.Rows.Add(array)
        Next




        'Dim xml As New Xml.XmlTextReader("archivo.xml")

        'While xml.Read
        '    If xml.NodeType = System.Xml.XmlNodeType.Element Then
        '        MessageBox.Show(xml.Name)
        '    End If
        'End While



    End Sub

martes, 4 de junio de 2019

verificar datos null

 If dr(3) Is DBNull.Value Then
                    Continue For
                End If