martes, 30 de julio de 2019
servicio timer elapsed
SystemTimers.Timer
Timer1_Elapsed(Me, Nothing)
Etiquetas:
servicio,
Timer,
windows service
jueves, 25 de julio de 2019
ordenar elementos combobox
ComboBox1.Sorted = True
Buscar todos los archivos en todos los directorios
Dim array() As String = Directory.GetFiles(ruta_carpeta, "*", SearchOption.AllDirectories)
buscar texto en string con regex
Dim rgx As String = ".PDF"
Dim rx As Regex = New(rgx)
If rx.IsMatch("c:\archivo.PDF") Then
End If
Dim rx As Regex = New(rgx)
If rx.IsMatch("c:\archivo.PDF") Then
End If
carpetas directorios
Public Function get_fecha(ByVal f As String) As String
Dim t As FileInfo = New FileInfo(f)
Return t.Directory.Parent.Parent.ToString & t.Directory.Parent.ToString & t.Directory.Name
End Function
Dim t As FileInfo = New FileInfo(f)
Return t.Directory.Parent.Parent.ToString & t.Directory.Parent.ToString & t.Directory.Name
End Function
Etiquetas:
carpetas,
directorios,
FileInfo
martes, 23 de julio de 2019
boleta declaración de cumplimiento
https://www4.sii.cl/certBolElectDteInternet
lunes, 22 de julio de 2019
tabla en html
tr: table row (fila de tabla)
td: table data (celda de una tabla)
<table border="5" bordercolor="#ff0000">
<tr>
<td>Cell A</td>
<td>Cell B</td>
<td>Cell C</td>
</tr>
</table>
td: table data (celda de una tabla)
<table border="5" bordercolor="#ff0000">
<tr>
<td>Cell A</td>
<td>Cell B</td>
<td>Cell C</td>
</tr>
</table>
jueves, 18 de julio de 2019
lista de procesos
Imports System.IO
Public Class Form1
Public t As Timer
Private mtimers() As Timer
Private sc1 As New Object
Private sc2 As New Object
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim max As Integer = 2
ReDim mtimers(max)
For i As Integer = 0 To max
t = New Timer
If i = 0 Then
t.Interval = 100 * 1
ElseIf i = 1 Then
t.Interval = 1000 * 1
ElseIf i = 2 Then
t.Interval = 1000 * 30
End If
t.Enabled = True
t.Tag = i + 1
AddHandler t.Tick, AddressOf Timer_Tick
mtimers(i) = t
Next
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As Timer = DirectCast(sender, Timer)
Select Case timer.Tag
Case "1"
Dim th1 As Threading.Thread
'th1 = New Threading.Thread(AddressOf function1)
th1 = New Threading.Thread(Sub() Me.function1(7))
th1.Start()
'Dim sw As New StreamWriter("test1.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
'sw.Close()
'While True
'End While
'timer.Stop()
Case "2"
'MessageBox.Show("TAG 2")
Dim th2 As Threading.Thread
th2 = New Threading.Thread(AddressOf function2)
th2.Start()
'Dim sw As New StreamWriter("test2.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
'sw.Close()
Case 3
Dim th3 As Threading.Thread
th3 = New Threading.Thread(AddressOf function3)
th3.Start()
End Select
End Sub
Private Sub function1(ByVal id As Integer)
SyncLock sc1
'If id = 1 Then
' Exit Sub
'End If
'While True
' Threading.Thread.Sleep(1000)
'End While
Dim sw As New StreamWriter("test1.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End SyncLock
End Sub
Private Sub function2()
SyncLock sc1
Dim sw As New StreamWriter("test1.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.WriteLine("hola!")
sw.Close()
End SyncLock
End Sub
Private Sub function3()
Dim sw As New StreamWriter("test3.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
For Each t As Timer In mtimers
t.Stop()
Next
End Sub
End Class
' https://www.dreamincode.net/forums/topic/140657-how-to-use-the-timer-as-array/
' http://vbcity.com/forums/t/36812.aspx
' https://social.msdn.microsoft.com/Forums/vstudio/en-US/ce7214c3-2116-4cfa-bb70-58ba2997cea7/stop-all-timers-at-once?forum=vbgeneral
Public Class Form1
Public t As Timer
Private mtimers() As Timer
Private sc1 As New Object
Private sc2 As New Object
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim max As Integer = 2
ReDim mtimers(max)
For i As Integer = 0 To max
t = New Timer
If i = 0 Then
t.Interval = 100 * 1
ElseIf i = 1 Then
t.Interval = 1000 * 1
ElseIf i = 2 Then
t.Interval = 1000 * 30
End If
t.Enabled = True
t.Tag = i + 1
AddHandler t.Tick, AddressOf Timer_Tick
mtimers(i) = t
Next
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As Timer = DirectCast(sender, Timer)
Select Case timer.Tag
Case "1"
Dim th1 As Threading.Thread
'th1 = New Threading.Thread(AddressOf function1)
th1 = New Threading.Thread(Sub() Me.function1(7))
th1.Start()
'Dim sw As New StreamWriter("test1.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
'sw.Close()
'While True
'End While
'timer.Stop()
Case "2"
'MessageBox.Show("TAG 2")
Dim th2 As Threading.Thread
th2 = New Threading.Thread(AddressOf function2)
th2.Start()
'Dim sw As New StreamWriter("test2.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
'sw.Close()
Case 3
Dim th3 As Threading.Thread
th3 = New Threading.Thread(AddressOf function3)
th3.Start()
End Select
End Sub
Private Sub function1(ByVal id As Integer)
SyncLock sc1
'If id = 1 Then
' Exit Sub
'End If
'While True
' Threading.Thread.Sleep(1000)
'End While
Dim sw As New StreamWriter("test1.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End SyncLock
End Sub
Private Sub function2()
SyncLock sc1
Dim sw As New StreamWriter("test1.txt", True)
'sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.WriteLine("hola!")
sw.Close()
End SyncLock
End Sub
Private Sub function3()
Dim sw As New StreamWriter("test3.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
For Each t As Timer In mtimers
t.Stop()
Next
End Sub
End Class
' https://www.dreamincode.net/forums/topic/140657-how-to-use-the-timer-as-array/
' http://vbcity.com/forums/t/36812.aspx
' https://social.msdn.microsoft.com/Forums/vstudio/en-US/ce7214c3-2116-4cfa-bb70-58ba2997cea7/stop-all-timers-at-once?forum=vbgeneral
threads con parámetros
Dim th1 As Threading.Thread
th1 = New Threading.Thread(Sub() Me.function(1))
th1.Start()
Private Sub function1(ByVal id As Integer)
End Sub
fuente
th1 = New Threading.Thread(Sub() Me.function(1))
th1.Start()
Private Sub function1(ByVal id As Integer)
End Sub
fuente
lista de funciones con timer
Imports System.IO
Public Class Form1
Public t As Timer
Private mtimers() As Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim mtimers(1)
For i As Integer = 0 To 1
t = New Timer
t.Interval = 1000 * (i + 1)
t.Enabled = True
t.Tag = i + 1
AddHandler t.Tick, AddressOf Timer_Tick
mtimers(i) = t
Next
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As Timer = DirectCast(sender, Timer)
Select Case timer.Tag
Case "1"
Dim sw As New StreamWriter("test1.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
'timer.Stop()
Case "2"
'MessageBox.Show("TAG 2")
Dim sw As New StreamWriter("test2.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End Select
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
For Each t As Timer In mtimers
t.Stop()
Next
End Sub
End Class
fuente1
fuente2
fuente3
Public Class Form1
Public t As Timer
Private mtimers() As Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReDim mtimers(1)
For i As Integer = 0 To 1
t = New Timer
t.Interval = 1000 * (i + 1)
t.Enabled = True
t.Tag = i + 1
AddHandler t.Tick, AddressOf Timer_Tick
mtimers(i) = t
Next
End Sub
Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As Timer = DirectCast(sender, Timer)
Select Case timer.Tag
Case "1"
Dim sw As New StreamWriter("test1.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
'timer.Stop()
Case "2"
'MessageBox.Show("TAG 2")
Dim sw As New StreamWriter("test2.txt", True)
sw.WriteLine(Now.ToString("HH:mm:ss"))
sw.Close()
End Select
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
For Each t As Timer In mtimers
t.Stop()
Next
End Sub
End Class
fuente1
fuente2
fuente3
Suscribirse a:
Comentarios (Atom)