elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)
0 Usuarios y 3 Visitantes están viendo este tema.
Páginas: 1 ... 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [22] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ... 58 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 480,246 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #210 en: 23 Junio 2013, 01:45 am »

Por cierto, y lo demás que me comentas, que opinas, has ido a saco al Timer y no me has comentado nada sobre lo demás. :¬¬ :xD :xD

No tenía nada más que decir al respecto... pero bueno, si quieres algún tipo de opinión... tu lo has querido xD :

1. Aunque no describes las cosas por sus términos correctos al menos hay muchos comentarios, eso es algo de agradecer que siempre me gusta ver en los codes...
2. El mports NET sobra, no lo utilizas en ese código...
3. No me gusta que importes "IO" para evitar escribirlo en 1 instrucción pero en la otra lo sigas escribiendo.
4. Me parece excesivo comprobar cada 15 segundos una actualización del programa :-/, yo lo comprobaría al ejecutar la aplicación y ya está, pero bueno, esto ya...pa gustos colores.
5. Es un code básico, cumple su función, no puedo opinar mucho más sobre el code, y lo otro...bueno, son snippets copiados, así que tampoco puedo opinar..

Citar
PD: Tengo una duda... El "temer" sigue activado en los otros forms? Es que recuerdo que tuve un conflicto con un Timer en otro Form y era por que no lo pasaba
...
...Veo que no hemos aprendido nada en todo este tiempo IKillNukes...

Contéstate tu mismo la pregunta: ¿El timer lo instancias en otros forms/classes?

Saludos


« Última modificación: 23 Junio 2013, 01:47 am por EleKtro H@cker » En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #211 en: 23 Junio 2013, 11:14 am »

Sobre lo del Timer, yo recuerdo que una vez tuve un conflicto en otro Form que no tenía que ver nada con ese Timer, y el caso es que cuando le daba dispose al Form creo que se paraba.... No se ni lo que digo xD

A ver si termino el Updater. :P


En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #212 en: 23 Junio 2013, 14:42 pm »

en otro Form que no tenía que ver nada con ese Timer,

el caso es que cuando le daba dispose al Form creo que se paraba....

Si haces eso no se para el Timer, diréctamente lo destruyes, ya te expliqué porque...

saludos!
En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #213 en: 23 Junio 2013, 15:00 pm »

Gracias, entre sarcasmos e ironías no pillaba muy bien a lo que te referias. Agradezco que hayas sido claro. :laugh:

Sobre lo de que 15 secs es excesivo, voy a hacer que el timer se pueda configurar de la manera que tu has dicho, eso ya lo pensé, pero me dije que sería mas hardcore hacer que se comprobase cada X secs. :)



Con tu cortesía has provocado un error :laugh:

Citar
Error   1   End of statement expected.   C:\Users\Alvaro\Documents\IkillLauncher\IkillLauncher\frmMain.vb   31   56   IkillLauncher

Me refiero a esta parte de code:

Código
  1. Dim WithEvents temer As System.Windows.Forms.Timer With {.Interval = 15000, .Enabled = True}
« Última modificación: 23 Junio 2013, 15:05 pm por Ikillnukes » En línea


Interesados hablad por Discord.
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #214 en: 23 Junio 2013, 15:26 pm »

@IKillnukes

Hola

1. No te he dicho nada con sarcasmo, quizás serio si (ya sabes porque), pero sarcasmo no.

Con tu cortesía has provocado un error :laugh:
Código
  1. Dim WithEvents temer As System.Windows.Forms.Timer With {.Interval = 15000, .Enabled = True}

2. Obviamente no puedes modificar las propiedades de un objeto que no has instanciado... vuelve a leer la línea que te puse y copiala tal cual la puse, y luego ya... intenta comprender las cosas y porque tu línea te da error y la mia no.

3. Este hilo es para postear snippets, porfavor no alarguemos más esta conversación con tus dudas, ya están resueltas.

saludos
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #215 en: 23 Junio 2013, 15:45 pm »

Ejemplo de como usar la librería "Thresher" para crear un Bot de IRC.

http://thresher.sourceforge.net/

Código
  1. Module Module1
  2.  
  3.    Sub Main()
  4.        Dim bot As New IRCBot()
  5.        bot.BotStart()
  6.    End Sub
  7.  
  8.    Public Class IRCBot
  9.        Private conn As Sharkbite.Irc.Connection
  10.  
  11.        Public Sub BotStart()
  12.            CreateConnection()
  13.            AddHandler conn.Listener.OnRegistered, AddressOf OnRegistered
  14.            AddHandler conn.Listener.OnPublic, AddressOf OnPublic
  15.            AddHandler conn.Listener.OnPrivate, AddressOf OnPrivate
  16.            AddHandler conn.Listener.OnError, AddressOf OnError
  17.            AddHandler conn.Listener.OnDisconnected, AddressOf OnDisconnected
  18.        End Sub
  19.  
  20.        Public Sub CreateConnection()
  21.            Dim server As String = "irc.freenode.net"
  22.            Dim nick As String = "Dios"
  23.            Sharkbite.Irc.Identd.Start(nick)
  24.            Dim cargs As Sharkbite.Irc.ConnectionArgs = New Sharkbite.Irc.ConnectionArgs(nick, server)
  25.            conn = New Sharkbite.Irc.Connection(cargs, False, False)
  26.            Try
  27.                conn.Connect()
  28.                Console.WriteLine("Connected to server")
  29.            Catch e As Exception
  30.                Console.WriteLine("Error during connection process.")
  31.                Console.WriteLine(e.ToString)
  32.                Sharkbite.Irc.Identd.Stop()
  33.            End Try
  34.        End Sub
  35.  
  36.        Public Sub OnRegistered()
  37.            Try
  38.                Sharkbite.Irc.Identd.Stop()
  39.                conn.Sender.Join("#elektrohacker")
  40.                Console.WriteLine("channel joined")
  41.            Catch e As Exception
  42.                Console.WriteLine("Error in OnRegistered(): " & e.Message)
  43.            End Try
  44.        End Sub
  45.  
  46.        Public Sub OnPublic(ByVal user As Sharkbite.Irc.UserInfo, ByVal channel As String, ByVal message As String)
  47.            conn.Sender.ChangeTopic(channel, "New topic")
  48.            conn.Sender.PrivateMessage(channel, user.Nick & ": " & message)
  49.            conn.Sender.PublicMessage(channel, user.Nick & ": " & message)
  50.        End Sub
  51.  
  52.        Public Sub OnPrivate(ByVal user As Sharkbite.Irc.UserInfo, ByVal message As String)
  53.            If message = "die" Then
  54.                conn.Disconnect("Goodbye!")
  55.            End If
  56.        End Sub
  57.  
  58.        Public Sub OnError(ByVal code As Sharkbite.Irc.ReplyCode, ByVal message As String)
  59.            Console.WriteLine("An error of type " + code + " due to " + message + " has occurred.")
  60.        End Sub
  61.  
  62.        Public Sub OnDisconnected()
  63.            Console.WriteLine("Connection to server closed!")
  64.        End Sub
  65.    End Class
  66.  
  67. End Module
« Última modificación: 23 Junio 2013, 15:55 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #216 en: 27 Junio 2013, 17:20 pm »

Hoy pensé en añadir la funcionalidad de seleccionar todo el texto haciendo triple click sobre un textbox... y he dado con este snippet: http://www.codeproject.com/Articles/23498/A-Simple-Method-for-Handling-Multiple-Clicking-on

Es un contador de clicks, así que se puede utilizar como Triple-Click, o Cuadruple-Click o lo que quieran... xD

Código
  1. Public Class Form1
  2.  
  3. #Region " Mouse-Click Count "
  4.  
  5.    ''' <summary>
  6.    ''' The Click-Timer area bounds.
  7.    ''' </summary>
  8.    ''' <remarks></remarks>
  9.    Private ClickArea As Rectangle
  10.  
  11.    ''' <summary>
  12.    ''' The mouse button clicked.
  13.    ''' </summary>
  14.    ''' <remarks></remarks>
  15.    Private ClickButton As MouseButtons
  16.  
  17.    ''' <summary>
  18.    ''' Accumulate clicks for the Click-Timer.
  19.    ''' </summary>
  20.    ''' <remarks></remarks>
  21.    Private ClickCount As Int32
  22.  
  23.    ''' <summary>
  24.    ''' Save the Click-Timer double-click delay time (ms).
  25.    ''' </summary>
  26.    ''' <remarks></remarks>
  27.    Private ClickDelay As Int32 = SystemInformation.DoubleClickTime
  28.  
  29.    ''' <summary>
  30.    ''' String description of the appropriate owner of the Click-Timer expiry event.
  31.    ''' </summary>
  32.    ''' <remarks></remarks>
  33.    Private ClickOwner As String = ""
  34.  
  35.    ''' <summary>
  36.    ''' Save the Click-Timer double-click area bounds.
  37.    ''' </summary>
  38.    ''' <remarks></remarks>
  39.    Private ClickSize As Size = SystemInformation.DoubleClickSize
  40.  
  41.    ''' <summary>
  42.    ''' Create a new Click-Timer with events.
  43.    ''' </summary>
  44.    ''' <remarks></remarks>
  45.    Private WithEvents ClickTimer As New Timer
  46.  
  47.    ''' <summary>
  48.    ''' Click-Timer "Tick" event handler.
  49.    ''' </summary>
  50.    ''' <param name="sender">Event object owner.</param>
  51.    ''' <param name="e">Event arguments.</param>
  52.    ''' <remarks></remarks>
  53.    Private Sub ClickTimer_TickHandler(ByVal sender As Object, ByVal e As EventArgs) Handles ClickTimer.Tick
  54.        Me.ClickTimer.Stop()
  55.        Me.ClickCount = 0
  56.    End Sub
  57.  
  58.    ''' <summary>
  59.    ''' Initialise the Click-Timer with Owner and valid double-click area.
  60.    ''' </summary>
  61.    ''' <param name="aOwnerControl">Click-Timer owner control (string).</param>
  62.    ''' <param name="aMouseButton">Mouse button clicked.</param>
  63.    ''' <param name="aClickPoint">Click point for definition of the valid double-click area.</param>
  64.    ''' <remarks></remarks>
  65.    Private Sub ClickTimer_Initialise(ByVal aOwnerControl As String, _
  66.                                      ByVal aMouseButton As MouseButtons, _
  67.                                      ByVal aClickPoint As Point)
  68.  
  69.        ' Stop the Click-Timer.
  70.        Me.ClickTimer.Stop()
  71.        ' Save the owner control text.
  72.        Me.ClickOwner = aOwnerControl
  73.        ' Save the mouse button.
  74.        Me.ClickButton = aMouseButton
  75.        ' This is the first click.
  76.        Me.ClickCount = 1
  77.        ' Define the valid double-click area for any multi-clicking.
  78.        Me.ClickArea = New Rectangle _
  79.              (aClickPoint.X - Me.ClickSize.Width \ 2 _
  80.              , aClickPoint.Y - Me.ClickSize.Height \ 2 _
  81.              , Me.ClickSize.Width, Me.ClickSize.Height)
  82.        ' Set the system default double-click delay.
  83.        Me.ClickTimer.Interval = Me.ClickDelay
  84.        ' Start the Click-Timer.
  85.        Me.ClickTimer.Start()
  86.  
  87.    End Sub
  88.  
  89.    ''' <summary>
  90.    ''' Register a mouse click (or double click) event.
  91.    ''' </summary>
  92.    ''' <param name="aOwnerControl">Click-Timer owner control (string).</param>
  93.    ''' <param name="aMouseButton">Mouse button clicked.</param>
  94.    ''' <param name="aClickPoint">Click point for definition of the valid double-click area.</param>
  95.    ''' <remarks></remarks>
  96.    Private Sub ClickTimer_Click(ByVal aOwnerControl As String, _
  97.                                 ByVal aMouseButton As MouseButtons, _
  98.                                 ByVal aClickPoint As Point)
  99.  
  100.        ' Handle this click event.
  101.        If Me.ClickTimer.Enabled Then
  102.            ' The Click-Timer is going, stop it and check we haven't changed controls.
  103.            Me.ClickTimer.Stop()
  104.            If Me.ClickOwner = aOwnerControl _
  105.            AndAlso Me.ClickButton = aMouseButton _
  106.            AndAlso Me.ClickArea.Contains(aClickPoint) Then
  107.                ' Working with the same control, same button within a valid double-click area so bump the count.
  108.                Me.ClickCount += 1
  109.                ' Set the system default double-click delay.
  110.                Me.ClickTimer.Interval = Me.ClickDelay
  111.                ' Start the Click-Timer.
  112.                Me.ClickTimer.Start()
  113.            Else
  114.                ' Not working with the same control. Initialise the Click-Timer.
  115.                Me.ClickTimer_Initialise(aOwnerControl, aMouseButton, aClickPoint)
  116.            End If
  117.        Else
  118.            ' The timer is not enabled. Initialise the Click-Timer.
  119.            Me.ClickTimer_Initialise(aOwnerControl, aMouseButton, aClickPoint)
  120.        End If
  121.  
  122.    End Sub
  123.  
  124. #End Region
  125.  
  126.    Private Sub TextBox1_Clicked(ByVal sender As Object, ByVal e As MouseEventArgs) _
  127.    Handles TextBox1.MouseClick, TextBox1.MouseDoubleClick
  128.  
  129.        Me.ClickTimer_Click(sender.name, e.Button, e.Location)
  130.  
  131.        If ClickCount = 3 Then ' Triple Click to select all text.
  132.            sender.SelectAll()
  133.        End If
  134.  
  135.    End Sub
  136.  
  137. End Class

Saludos.
« Última modificación: 27 Junio 2013, 17:22 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #217 en: 28 Junio 2013, 12:34 pm »

Función para comprobar si un ListView contiene cierto texto:

PD: La verdad es que no es muy útil a menos que le añada más opciones, la hice porque muchas veces se me olvida el nombre del método "FindItemWithText" y eso me hace perder tiempo :silbar:

Código
  1. #Region " Find ListView Text "
  2.  
  3.    ' [ Find ListView Text Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Find_ListView_Text(ListView1, "Hello"))
  9.    ' If Find_ListView_Text(ListView1, "Hello") Then...
  10.  
  11.    Private Function Find_ListView_Text(ByVal ListView As ListView, ByVal Text As String) As Boolean
  12.        Try : Return Convert.ToBoolean(ListView.FindItemWithText(Text)) : Catch : Return True : End Try
  13.    End Function
  14.  
  15. #End Region

Ejemplo de uso:

Código
  1.    Private Sub Status_Timer_Tick(sender As Object, e As EventArgs) Handles Status_Timer.Tick
  2.  
  3.        If Find_ListView_Text(ListView1, TextBox_Filename.Text) Then
  4.            Label_Status.Text = "Current song found"
  5.        Else
  6.            Label_Status.Text = "Current song not found"
  7.        End If
  8.  
  9.    End Sub
« Última modificación: 28 Junio 2013, 12:36 pm por EleKtro H@cker » En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.788



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #218 en: 28 Junio 2013, 16:30 pm »

[Textbox] Show end part of text

Este snippet no se muy bien como explicarlo en pocas palabras, así que lo voy a explicar con imágenes...

Cuando excedemos el límite visible del textbox, la parte del final, es decir la parte derecha no se muestra:



Pues con este snippet omitiremos la parte de la izquierda, mostrando hasta la parte final del texto:



Código
  1.    Private Sub TextBox_TextChanged(sender As Object, e As EventArgs) _
  2.    Handles TextBox1.TextChanged
  3.  
  4.        ' If the text reaches the writable box size then this shows the end part of the text.                                                          
  5.        sender.Select(sender.TextLength, sender.TextLength)
  6.  
  7.    End Sub

Saludos!
En línea

z3nth10n


Desconectado Desconectado

Mensajes: 1.583


"Jack of all trades, master of none." - Zenthion


Ver Perfil WWW
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #219 en: 28 Junio 2013, 16:48 pm »

A ti te dejan doble postear? >:(
Muy buenos snippets :)
En línea


Interesados hablad por Discord.
Páginas: 1 ... 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [22] 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ... 58 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines