jueves, 17 de octubre de 2019

Estandarizar fecha para distintos lenguages y sistemas operativos

Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture(CultureInfo.CurrentCulture.Name)
ci.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy" System.Threading.Thread.CurrentThread.CurrentCulture = ci



fuente

suma y resta día


formato entrada fecha=20191017

Public Function suma_resta_dia(ByVal fecha As String, ByVal dias As Integer) As Integer
        fecha = fecha.Insert(4, "-").Insert(7, "-")
        Dim dt As DateTime = DateTime.Parse(fecha).AddDays(dias)
        Return dt.ToString("yyyyMMdd")
    End Function

miércoles, 16 de octubre de 2019

wsconfig

-Agregar contraseña a las tareas
-Agregar hora de inicio

martes, 15 de octubre de 2019

fecha máxima

DateTimePicker.MaxDate = DateTime.Today

cambiar formato fecha


fecha='20191009

Public Function get_fecha_inicio(ByVal fecha As String) As String
        Dim tmp As String = ""
        tmp += fecha.Substring(6, 2) & "-"
        tmp += fecha.Substring(4, 2) & "-"
        tmp += fecha.Substring(0, 4)
        Return tmp
    End Function

datagridview columna y fila

columna=DgvTareas.CurrentCell.ColumnIndex
fila=Form1.DgvTareas.CurrentRow.Index

fuente

date time picker formato

DateTimePicker.Format = DateTimePickerFormat.Custom
DateTimePicker.CustomFormat = "HH:mm:ss"


DateTimePicker.CustomFormat = "HH:mm:ss tt"  --> 23:34:54 AM/PM


fuente

lunes, 14 de octubre de 2019

windows form activo

 If Application.OpenForms.OfType(Of windows_form1).Any Then
            MessageBox.Show("windows form1")
        ElseIf Application.OpenForms.OfType(Of windows_form2).Any Then
            MessageBox.Show("windows_form2")
        End If

fuente

viernes, 11 de octubre de 2019

Bloquear tabpage

Private Sub TabControl1_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
       If e.TabPageIndex = 1 Then
           e.Cancel = True
       End If
    End Sub

fuente

miércoles, 9 de octubre de 2019

Directorio de un archivo

archivo = "D:\programa\bin\archivos\test\archivo.xml"

Dim ruta As String = New FileInfo(archivo).Directory.FullName
Dim ruta As String = Path.GetDirectoryName(archivo)