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>

lunes, 20 de noviembre de 2017

jueves, 16 de noviembre de 2017

Quitar los caracteres de un string función Replace

'fecha = data(j + 23)
 'fecha = fecha.Replace(".", String.Empty)



Formato fecha y hora para sql 2005 y sql 2008

declare @dateserver varchar(20)
set @dateserver = CONVERT(varchar(10), GETDATE(), 121)
print @dateserver

2017-11-16

DECLARE @horacreacion VARCHAR(8)
SET @horacreacion = CONVERT(VARCHAR(8), GETDATE(), 108)
print @horacreacion

16:17:12


Sólo consulta
SELECT CONVERT(VARCHAR(10), GETDATE(),120)
SELECT GETDATE()

declare @dateserver varchar(20)
set @dateserver = dateadd(day,45,CAST(GETDATE() AS DATE))
print @dateserver  --imprime yyyy-MM-dd

fuente



Estilos de fecha:
https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql




Cambiar nombre a proyecto en visual net

https://www.youtube.com/watch?v=SjGCfj04WoM

Volver al icono por defecto en WindowsForm

Properties
Icon
click botón derecho mouse
seleccionar Reset

TreeView para opciones

Public Class Form1


    Private f As Form
 
    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

        Dim node As TreeNode = TreeView1.SelectedNode

        Select Case node.Text

            Case "General"
                'general.TextBox1.Enabled = False
                f.Dispose()
                f = New general()
                f.TopLevel = False
                Me.Panel1.Controls.Add(f)
                f.Dock = DockStyle.Fill
                f.Show()



            Case "Factura electrónica"
                f.Dispose()
                f = New fa()
                f.TopLevel = False
                Me.Panel1.Controls.Add(f)
                f.Dock = DockStyle.Fill
                f.Show()
            Case "Nota de credito"
                f.Dispose()
                f = New nc()
                f.TopLevel = False
                Me.Panel1.Controls.Add(f)
                f.Dock = DockStyle.Fill
                f.Show()


        End Select

    End Sub

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



        'TreeView1.HideSelection = True
        TreeView1.TabIndex = 0

        f = New general()
        f.TopLevel = False
        Me.Panel1.Controls.Add(f)
        f.Dock = DockStyle.Fill
        f.Show()
    End Sub
End Class

no copiar,pegar,seleccionar en TextBox

ShortcutsEnabled = False

Bloquear cursor TextBox

Imports System.Runtime.InteropServices

Public Class general

    <DllImport("user32")> _
    Private Shared Function HideCaret(ByVal hWnd As IntPtr) As Integer
    End Function

    Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus
        HideCaret(TextBox1.Handle)
    End Sub

    Private Sub general_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Cursor = Cursors.Arrow
    End Sub
End Class

miércoles, 15 de noviembre de 2017

Cantidad de decimales


 Dim n As Double = 56.7865
  n = n.ToString("N3")
  n = Math.Round(n, 3)


fuente: https://stackoverflow.com/questions/16209509/what-is-tostringn0-format

Limpiar un TextBox

TextBox1.Clear()

viernes, 10 de noviembre de 2017

Eliminar índice de una tabla

DROP INDEX nombre_indice on dbo.DTE_recibos

Consultar si existe un índice en una tabla

IF EXISTS (select * from sys.indexes where object_id = (select object_id from sys.objects where name = 'DTE_recibos') and name ='fecha_emision')
print 'ok'
else
print 'bad'


IF EXISTS (SELECT * FROM sys.indexes WHERE
object_id = (SELECT object_id FROM sys.objects WHERE name = 'DTE_recibos') AND name ='fecha_emision')
BEGIN
DROP INDEX fecha_emision on dbo.DTE_recibos
END
ELSE
BEGIN
print '435345'
END

jueves, 9 de noviembre de 2017

Fórmula modulo

x % y = x - (10 * (x/10))  <-- fórmula para el modulo

z = x - (10 * (x/10))
if z = 0  then montoNeto
if z <= 5 then montoNeto - z
if z >= 6 then montoNeto + (10-z)

miércoles, 8 de noviembre de 2017

Borrar procedimiento almacenado pasando el nombre por variable

declare @sp varchar(1000)
set @sp ='DROP PROCEDURE ' + 'SP_name'
print @sp
exec(@sp)

obtener el nombre de la base de datos y guardar en una variable

declare @p varchar(10) = db_name()
print @p

Ingresar a certificación servicio de impuestos internos


  1. Ingresar a la página del servicio de impuestos internos
  2. Servicios online
  3. Factura electrónica
  4. Sistema de facturación de mercado
  5. Menú postulantes
  6. Ambiente de certificación y prueba

lunes, 6 de noviembre de 2017

Extraer string con expresiones regulares

Dim rgx As New Regex("GO")
Dim j As Long = rgx.Match(sp).Index ' donde inicia
Dim fin As Long = string.Length
Dim match As Match = rgx.Match(string)
If match.Success Then
Dim i As Integer = match.Index
Dim st As String = string.Substring(i, fin - i)
End If