miércoles, 27 de diciembre de 2017

update left join

Update t 
SET 
       t.Column1=100
FROM 
       myTableA t 
LEFT JOIN 
       myTableB t2 
ON 
       t2.ID=t.ID
fuente: https://stackoverflow.com/questions/6335388/update-and-left-outer-join-statements

martes, 26 de diciembre de 2017

Validar números TextBox

If String.IsNullOrEmpty(tbnumber.Text.Trim("0")) Then
            tbnumber.Clear()
            MessageBox.Show("Ingrese un valor mayor que cero")

            Exit Sub
        Else
            Dim number As Long = 0
            Dim result As Boolean = Int64.TryParse(tbnumber.Text.Trim, number)

            If Not result Then
                MessageBox.Show("Número no válido")
            Else
                tbnumber.Text = tbnumber.Text.TrimStart("0")
            End If

            MessageBox.Show(result)
        End If

Deshabilitar copiar-pegar en un TextBox

Propiedades
ShortcutsEnabled = False

martes, 19 de diciembre de 2017

viernes, 15 de diciembre de 2017

Servicio modo debug

Service1.Designer.vb

#If DEBUG Then
        Dim x As New Service1
        x.Ondebug()
#Else
#End If




' The main entry point for the process
    <MTAThread()> _
    <System.Diagnostics.DebuggerNonUserCode()> _
    Shared Sub Main()

#If DEBUG Then
        Dim debug_service As New Service1
        debug_service.Ondebug()
#Else


        Dim ServicesToRun() As System.ServiceProcess.ServiceBase

        ' More than one NT Service may run within the same process. To add
        ' another service to this process, change the following line to
        ' create a second service object. For example,
        '
        '   ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
        '
        ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1}

        System.ServiceProcess.ServiceBase.Run(ServicesToRun)
#End If
    End Sub

miércoles, 13 de diciembre de 2017

Crear directorio

Try
            Directory.CreateDirectory("nombreDirectorio")
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try

jueves, 30 de noviembre de 2017

Acerca de...

Imports System.Windows.Forms
Imports System.Runtime.InteropServices

Public Class Form1

    Private Const WM_SYSCOMMAND As Integer = 274
    Private Const MF_STRING As Integer = 0
    Private Const MF_SEPARATOR As Integer = 2048

    <DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
    Private Shared Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
    End Function
    <DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
    Private Shared Function AppendMenu(ByVal hMenu As IntPtr, ByVal uFlags As Integer, ByVal uIDNewItem As Integer, ByVal lpNewItem As String) As Boolean
    End Function
    <DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
    Private Shared Function InsertMenu(ByVal hMenu As IntPtr, ByVal uPosition As Integer, ByVal uFlags As Integer, ByVal uIDNewItem As Integer, ByVal lpNewItem As String) As Boolean
    End Function

    Private SYSMENU_ABOUT_ID As Integer = 1

    Public Sub CustomForm()
    End Sub

    Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
        MyBase.OnHandleCreated(e)
        Dim hSysMenu As IntPtr = GetSystemMenu(Me.Handle, False)
        AppendMenu(hSysMenu, MF_SEPARATOR, 0, String.Empty)
        AppendMenu(hSysMenu, MF_STRING, SYSMENU_ABOUT_ID, "&About…")
    End Sub

    Protected Overrides Sub WndProc(ByRef m As Message)
        MyBase.WndProc(m)
        If (m.Msg = WM_SYSCOMMAND) AndAlso (CInt(m.WParam) = SYSMENU_ABOUT_ID) Then
            MessageBox.Show("Custom About Dialog")
        End If
    End Sub
End Class



fuente: https://stackoverflow.com/questions/4615940/how-can-i-customize-the-system-menu-of-a-windows-form

miércoles, 29 de noviembre de 2017

Limpiar un arreglo (array)

Dim readtext() As String = File.ReadAllLines("archivo.txt")
Array.Clear(readtext, 0, readtext.Length)

fuente: https://stackoverflow.com/questions/713867/what-is-the-best-way-to-clear-an-array-of-strings

ReDim readtext(0)

ReDim Preserve

Erase array fuente

martes, 28 de noviembre de 2017

Factura de exportación electrónica

RLV - DTE Aceptado con Reparos Leves
(HED-1-835) Export.: desde el 01-12-2017 sera obligatorio informar en la seccion <OtraMoneda> el <TpoMoneda> con valor "PESO CL"

Ejemplo:
<Totales>
  <TpoMoneda>DOLAR USA</TpoMoneda>
  <MntExe>52974</MntExe>
  <MntTotal>52974</MntTotal>
</Totales>
<OtraMoneda>
  <TpoMoneda>PESO CL</TpoMoneda>
  <TpoCambio>630.41</TpoCambio>
  <MntExeOtrMnda>33395339.34</MntExeOtrMnda>
  <MntTotOtrMnda>33395339.34</MntTotOtrMnda>
</OtraMoneda>