martes, 27 de diciembre de 2016

Recorrer un datagridview


        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            wr.WriteLine(DataGridView1(0, i).Value & "|" & DataGridView1(1, i).Value & "|" & DataGridView1(2, i).Value)
        Next


Agregar texto a botón en datagridview

-DataGridView Tasks -Edit Columns
-Seleccionar la columna Appearance:
-Text:
-UseColumnTextForButtonValue = True

jueves, 22 de diciembre de 2016

Botón para buscar archivo


        ' Dim openFileDialog1 As OpenFileDialog = New OpenFileDialog()
        Dim openFileDialog1 As New OpenFileDialog()
        openFileDialog1.Filter = "Acceso Directo (*.txt)|*.txt"
        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            tb_ruta_conex.Text = openFileDialog1.FileName
        Else
            Exit Sub
        End If


miércoles, 21 de diciembre de 2016

Extraer archivo de una ruta


Imports System.IO

'Obtener el nombre del archivo
Dim NombreDelArchivo As String = Path.GetFileName(ruta)

'Obtener el nombre del archivo sin extesión
Dim Archivo As String = Path.GetFileNameWithoutExtension(ruta)

miércoles, 14 de diciembre de 2016

Enviar archivos ftp bat

%windir%\system32\ftp.exe -s:%0
open 192.168.1.666 20
usuario
123
lcd C:\Users\archivos\Desktop\cc\x
binary
put Setup1.msi
quit
pause
fuente: http://www.ericphelps.com/batch/samples/ftp.script.txt

jueves, 1 de diciembre de 2016

Recorrer una lista y arreglo


Dim lista As List(Of String)
        For i As Integer = 0 To lista.Count - 1
            ' Código aquí...
        Next

Dim array() As String
        For j As Integer = 0 To array.Length - 1
            ' Código aquí...
        Next


martes, 29 de noviembre de 2016

CheckBox ocultar y mostrar contraseña


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = "esto es una prueba de UseSystemPasswordChar"
        TextBox1.UseSystemPasswordChar = True
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked Then
            TextBox1.UseSystemPasswordChar = False
        Else
            TextBox1.UseSystemPasswordChar = True
        End If
    End Sub
End Class


viernes, 25 de noviembre de 2016

Crear un archivo log


Dim log As StreamWriter = Nothing
' log = Nothing
Try
log = New StreamWriter("log.txt", False, System.Text.Encoding.UTF8)
registro(log)
Catch ex As Exception
End Try

' Pasar a una función

Public Function registro(ByVal log As StreamWriter) As String
log.WriteLine("texto")
End Function


martes, 22 de noviembre de 2016

Array variable is used before assigned a value



Dim varreglo() As String = Array.CreateInstance(GetType(String), 0)

fuente: http://stackoverflow.com/questions/25853677/array-variable-is-used-before-assigned-a-value

Conectar con SQL


Imports System.Data.SqlClient

Dim conex As String = "Data Source=SQLEXPRESS;Network Library=DBMSSOCN;Initial Catalog=BD;User ID=invitado;password=p455w0rd;Persist Security Info=False;Max Pool Size=4000;Enlist=true;Pooling=true"
Dim con As New SqlConnection(conex)

        Try
            con.Open()
            ' Insertar código aquí.
        Catch ex As Exception
            MessageBox.Show("Error!")
        Finally
            con.Close()
        End Try

'Try
'Catch SqlEx As SqlException
'End Try

fuente1: https://msdn.microsoft.com/es-cl/library/cc437979(v=vs.71).aspx fuente2: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlexception(v=vs.110).aspx

lunes, 21 de noviembre de 2016

Obtener directorio actual archivo ejecutable windows service

Dim path As String = System.IO.Path.GetDirectoryName(Application.ExecutablePath)
Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location

jueves, 17 de noviembre de 2016

Eliminar archivos de un directorio

Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim archivos() As String = Directory.GetFiles("c:\directorio", "*.*") ' sin backslash al final de la ruta del directorio
        For Each f As String In archivos
            File.Delete(f)
        Next
    End Sub
End Class

http://bit.ly/2f3pTKV

jueves, 3 de noviembre de 2016

Retornar un arreglo (array)

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str As String = "hola,chao,hallo,bye"
        Dim datos() As String = split_data(str)
    End Sub
    Public Function split_data(ByVal str As String) As String()
        Return str.Split(",")
    End Function
End Class

martes, 25 de octubre de 2016

Cambiar tipo de dato de una columna SQL

ejemplo:
ALTER TABLE nombre_tabla ALTER COLUMN columna_de_tabla CHAR(600)

miércoles, 12 de octubre de 2016

Borrar carpetas directorio actual

Dim path As String = Directory.GetCurrentDirectory
        Dim di As New DirectoryInfo(path)

        'Borra carpetas
        For Each dir_ As DirectoryInfo In di.GetDirectories

            Try
                dir_.Delete(True)
            Catch ex As Exception
                MessageBox.Show(ex.ToString())
            End Try
        Next

viernes, 7 de octubre de 2016

Verificar parte decimal de un número


'Limpia la parte decimal del número
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim z As String = "0,9990"
        Dim x As String = z.Split(",")(1)
        Dim y As Double = x / Math.Pow(10, z.Split(",")(1).Length)
        Dim n As String = y.ToString("0." + New String("#", 10))
        MessageBox.Show(n.Split(",")(1))
    End Sub

miércoles, 5 de octubre de 2016

Mostrar el archivo de solución en el Explorador de soluciones


image

image


Tools--->Options--->Projects and Solutions--->General--->Always show solution


fuente: https://blogs.msdn.microsoft.com/zainnab/2010/03/26/hide-or-show-the-solution-file-in-solution-explorer/

miércoles, 28 de septiembre de 2016

Opciones batch

/F : Sirve para forzar a Windows a que elimine un archivo.

jueves, 15 de septiembre de 2016

Validar campo emails SQL

SELECT * FROM clientes WHERE email NOT LIKE '%_@__%.__%' 'ejemplo .NET https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx

viernes, 9 de septiembre de 2016

Obtener archivos de la carpeta Debug y mostrarlos

Dim files() As String
files = System.IO.Directory.GetFiles(Application.StartupPath, "*.sql")
Dim x As String
For Each x In files
MessageBox.Show(x)
Next

'Las 6 líneas de arriba se pueden reducir a:
For Each x As String In System.IO.Directory.GetFiles(Application.StartupPath, "*.sql")
MessageBox.Show(x)
Next

lunes, 5 de septiembre de 2016

SQL Funciones

Ejemplo, función en SQL 2008 R2 que suma dos números:

CREATE FUNCTION sumar
(@n1 as int,
 @n2 as int
)
RETURNS INT
AS
BEGIN
DECLARE @r INT = 0
SET @r = @n1 + @n2
RETURN @r
END
GO
PRINT dbo.sumar(7,3) 

la función queda almacenada en la carpeta "Functions", "Scalar-value Functions"

jueves, 1 de septiembre de 2016

Operadores OrElse, AndAlso

OrElse
https://msdn.microsoft.com/es-es/library/ea1sssb2(v=vs.100).aspx

AndAlso
https://msdn.microsoft.com/en-us/library/cb8x3kfz(v=vs.100).aspx

martes, 30 de agosto de 2016

Extraer un número de un string y pasarlo a una variable tipo entero en SQL

Para este ejemplo el número(45) tiene sólo dos dígitos

DECLARE @newString VARCHAR(30) = '45,2000-01-01,2016-08-01'

DECLARE @number INTEGER
DECLARE @desde VARCHAR(10)
DECLARE @hasta VARCHAR(10)

SET @number = CAST(SUBSTRING(@newString,1,2) AS INTEGER)
SET @desde = SUBSTRING(@newString,4,10)
SET @hasta = SUBSTRING(@newString,15,10)

PRINT @number
PRINT @desde
PRINT @hasta

Imprime el número 45

martes, 23 de agosto de 2016

miércoles, 6 de julio de 2016

martes, 19 de abril de 2016

Crear procedimiento almacenado en SQL


USE BD  
GO
CREATE PROCEDURE NOMBRE_DEL_PROCEDIMIENTO
( --DECLARACIÓN DE VARIABLES

@id_version int,
@tipo_doc,
@fecha

) AS
--AQUÍ COMIENZA EL QUERY
SELECT...

jueves, 10 de marzo de 2016

Comparar listas

http://www.dotnetperls.com/list-equals
http://www.dotnetperls.com/list-vbnet

martes, 8 de marzo de 2016

Deshabilitar botón cerrar

Private Const CP_NOCLOSE_BUTTON As Integer = &H200
    Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim myCp As CreateParams = MyBase.CreateParams
            myCp.ClassStyle = myCp.ClassStyle Or CP_NOCLOSE_BUTTON
            Return myCp
        End Get
    End Property

fuente:
http://stackoverflow.com/questions/1743433/visually-remove-disable-close-button-from-title-bar-net
http://stackoverflow.com/questions/6172390/disabling-close-button-vb-net

Reemplazar en sql

update clientes
set bccXML = REPLACE(bccXML,';',',')

lunes, 7 de marzo de 2016

correo pop3

servidor: pop.gmail.com
puerto: 995
SSL: SI

https://support.google.com/mail/troubleshooter/6323470#ts=1665162

Ver o administrar los certificados

certmgr.msc

inicio-->ejecutar-->mmc

viernes, 4 de marzo de 2016

Anulación de facturas exentas

http://www.sii.cl/documentos/circulares/2000/circu39.htm
http://www.chilecont.cl/?page_id=1001

párrafo V (5), Relación con otros documentos.

viernes, 12 de febrero de 2016

viernes, 5 de febrero de 2016

Datagridview clic seleccionar toda la fila

SelectionMode: FullRowSelect




Seleccionar solo una fila
MultiSelect: False

Deshabilitar windowsForm padre cuando el windowsForm hijo está activo
Form1.ShowDialog()

Bloquear TextBox
ReadOnly : True

viernes, 29 de enero de 2016

Cisco AnyConnect Profiles

Local AnyConnect Profiles

XML and profile files are stored locally to the users machine. The location varies based on OS.

Windows XP
%ALLUSERSPROFILE%\Application Data\Cisco\ Cisco AnyConnect Secure Mobility Client\Profile

Windows Vista
%ProgramData%\Cisco\Cisco AnyConnect Secure Mobility Client\Profile

Windows 7
%ProgramData%\Cisco\Cisco AnyConnect Secure Mobility Client\Profile

Mac OS X
/opt/cisco/anyconnect/profile

Linux
/opt/cisco/anyconnect/profile

fuente: http://www.tunnelsup.com/locating-the-cisco-anyconnect-profiles

martes, 26 de enero de 2016

Recursos

http://bit.ly/1Pi0aNR

Team Viewer

http://download.teamviewer.com/download/version_8x/TeamViewer_Setup.exe
http://download.teamviewer.com/download/version_7x/TeamViewer_Setup.exe
http://download.teamviewer.com/download/version_5x/TeamViewer_Setup.exe


jueves, 21 de enero de 2016

Ejemplos data source

.\SQLEXPRESS
192.168.1.240\SQLEXPRESS
(local)\SQLEXPRESS
usuario-pc\SQLEXPRESS
127.0.0.1\sqlexpress

miércoles, 20 de enero de 2016

Borrar listado de servidores y contraseñas sql

SQL Server Management Studio 2014:
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin
SQL Server Management Studio 2012:
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
SQL Server Management Studio 2008:
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
SQL Server Management Studio 2005:
  • In Windows 8/7/Vista: C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
  • Windows XP: C:\Documents and Settings\%username%\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
fuente: http://www.top-password.com/blog/sql-server-management-studio-saved-password/

jueves, 14 de enero de 2016

Apagar y Reiniciar equipo

Apagar: shutdown.exe -s -t 00
Reiciniar: shutdown.exe -r -t 00

Leer archivo txt

Dim rd As New System.IO.StreamReader(rutaArchivo)
            Dim linea As String = rd.ReadLine()
            While linea IsNot Nothing
                'Código aquí...
                linea = rd.ReadLine()
            End While
            rd.Close()

martes, 12 de enero de 2016

Buscar y capturar ruta de un archivo

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim openfiledialog1 As New OpenFileDialog()
        Dim rutaArchivo As String = ""

        If openfiledialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            rutaArchivo = openfiledialog1.FileName()
            MessageBox.Show(rutaArchivo)
        End If
    End Sub