viernes, 28 de julio de 2017

Borrar archivos sin confirmación

del /F /Q

fuente: https://stackoverflow.com/questions/7160342/how-to-skip-are-you-sure-y-n-when-deleting-files-in-batch-files

Definir primer ítem visible ComboBox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.SelectedIndex = 0
    End Sub

jueves, 27 de julio de 2017

Cambiar nombre a servicio

-Doble clic a ProjectInstaller.vb
-Clic en ServiceInstaller1
-Parámetro ServiceName

NumericUpDown

Dim i As Integer = NumericUpDown1.Value

Seleccionar ítem ComboBox

Dim item As String = ComboBox1.SelectedItem()

Cargar lista de impresoras

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each printer As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
            ComboBox1.Items.Add(printer.Trim)
        Next
    End Sub

miércoles, 26 de julio de 2017

martes, 25 de julio de 2017

viernes, 21 de julio de 2017

Generar excepciones

Throw New System.Exception("Mensaje")


Mostrar sólo mensaje y no las líneas de error

Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Declaración de hilos


        Dim th1 As Thread = Nothing
        Dim th2 As Thread = Nothing

        th1 = New Thread(AddressOf thtask1)
        th1.Start()

        th2 = New Thread(AddressOf thtask2)
        th2.Start()


lunes, 3 de julio de 2017

Eliminar un proceso


Try
    For Each proc As Process In Process.GetProcessesByName("libros")
        proc.Kill()
    Next
  Catch ex As Exception
    MessageBox.Show(e.ToString)
  End Try