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
martes, 29 de noviembre de 2016
CheckBox ocultar y mostrar contraseña
Etiquetas:
CheckBox,
Contraseña,
Password,
UseSystemPasswordChar
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 Tryfuente1: 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
Etiquetas:
.net,
ejecutable,
ruta,
servicio
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 Classhttp://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
Suscribirse a:
Entradas (Atom)