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

 

 


Tema destacado: Tutorial básico de Quickjs


+  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 1 Visitante están viendo este tema.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 59 Ir Abajo Respuesta Imprimir
Autor Tema: Librería de Snippets para VB.NET !! (Compartan aquí sus snippets)  (Leído 484,558 veces)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #130 en: 31 Mayo 2013, 13:27 pm »

Una función para devolver una lista con todas las coincidencias de un RegEx:

Código
  1. #Region " RegEx Matches To List "
  2.  
  3.    ' [ RegEx Matches To List Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Dim str As String = "<span class=""genres""><a href=""http://www.mp3crank.com/genre/alternative"" rel=""tag"">Alternative</a> / <a href=""http://www.mp3crank.com/genre/indie"" rel=""tag"">Indie</a> / <a href=""http://www.mp3crank.com/genre/rock"" rel=""tag"">Rock</a></span>"
  9.    ' For Each match In RegEx_Matches_To_List(str, <a><![CDATA[tag">(\w+)<]]></a>.Value) : MsgBox(match) : Next
  10.  
  11.    Private Function RegEx_Matches_To_List(ByVal str As String, ByVal RegEx_Pattern As String) As List(Of String)
  12.  
  13.        Dim match As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(str, RegEx_Pattern)
  14.        Dim Match_List As New List(Of String)
  15.  
  16.        Do While match.Success
  17.            Match_List.Add(match.Groups(1).ToString)
  18.            match = match.NextMatch()
  19.            Application.DoEvents()
  20.        Loop
  21.  
  22.        Return Match_List
  23.  
  24.    End Function
  25.  
  26. #End Region





Unas cuantas expresiones regulares que he escrito para facilitar algunas taréas:

Código
  1.  
  2.    ' Dim str As String = <a><![CDATA[<href="http://www.mp3crank.com/feed"]]></a>.Value
  3.    ' MsgBox(Match_RegEx_MainBase_Url(Str)) ' Result: http://www.mp3crank.com
  4.  
  5.    Private Function Match_RegEx_MainBase_Url(ByVal str As String) As String
  6.  
  7.        ' Match criteria:
  8.        '
  9.        ' http://url.domain
  10.        ' https://url.domain
  11.        ' www.url.domain
  12.  
  13.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  14.        <a><![CDATA[(http://|https://|www).+\.[0-9A-z]]]></a>.Value)
  15.  
  16.        Return RegEx.Match(str).Groups(0).ToString
  17.    End Function

Código
  1.  
  2.    ' Dim str As String = <a><![CDATA[<href="http://www.mp3crank.com/feed"]]></a>.Value
  3.    ' MsgBox(Match_RegEx_Url(str)) ' Result: http://www.mp3crank.com/feed
  4.  
  5.    Private Function Match_RegEx_Url(ByVal str As String) As String
  6.  
  7.        ' Match criteria:
  8.        '
  9.        ' http://url
  10.        ' https://url
  11.        ' www.url
  12.  
  13.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  14.        <a><![CDATA[(http://|https://|www).+\b]]></a>.Value)
  15.  
  16.        Return RegEx.Match(str).Groups(0).ToString
  17.    End Function

Código
  1.  
  2.    ' Dim str As String = <a><![CDATA[href="http://www.mp3crank.com/the-rolling-stones/deluxe-edition.htm"]]></a>.Value
  3.    ' MsgBox(Match_RegEx_htm_html(str)) ' Result: http://www.mp3crank.com/the-rolling-stones/deluxe-edition.htm
  4.  
  5.    Private Function Match_RegEx_htm_html(ByVal str As String) As String
  6.  
  7.        ' Match criteria:
  8.        '
  9.        ' http://Text.htm
  10.        ' http://Text.html
  11.        ' https://Text.htm
  12.        ' https://Text.html
  13.        ' www.Text.htm
  14.        ' www.Text.html
  15.  
  16.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  17.        <a><![CDATA[(http://|https://|www).*\.html?]]></a>.Value)
  18.  
  19.        Return RegEx.Match(str).Groups(0).ToString
  20.    End Function

Código
  1.  
  2.    ' Dim str As String = <a><![CDATA[href=>Drifter - In Search of Something More [EP] (2013)</a>]]></a>.Value
  3.    ' MsgBox(Match_RegEx_Tag(str)) ' Result: Drifter - In Search of Something More [EP] (2013)
  4.  
  5.    Private Function Match_RegEx_Tag(ByVal str As String) As String
  6.  
  7.        ' Match criteria:
  8.        '
  9.        ' >..Text..<
  10.  
  11.        Dim RegEx As New System.Text.RegularExpressions.Regex( _
  12.        <a><![CDATA[>([^<]+?)<]]></a>.Value)
  13.  
  14.        Return RegEx.Match(str).Groups(1).ToString
  15.    End Function


« Última modificación: 31 Mayo 2013, 13:38 pm 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 #131 en: 31 Mayo 2013, 15:08 pm »

Deberías poner mi code para que cambien las imagenes al pasar el mouse...

Tengo otro code, que adapta una imagen al fondo del Form... (Es decir si el form es de 800x600 y la imagen 1024x768 se redimensiona automaticamente)

Un saludo.

Te paso los codes?  ;)


En línea


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

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #132 en: 31 Mayo 2013, 16:26 pm »

Deberías poner mi code para que cambien las imagenes al pasar el mouse...

Puedes colaborar publicando tus códigos aquí, yo publico solo lo mio, o lo que encuentro por ahí en zonas prohibidas de la red xD.
Eres libre de publicar aquí tus snippets.

Tengo otro code, que adapta una imagen al fondo del Form... (Es decir si el form es de 800x600 y la imagen 1024x768 se redimensiona automaticamente)

Miedo me da ese código, no sé si querrás publicar eso, te lo digo más que nada porque no le veo sentido ni utilidad cuando existe una propiedad para redimensionar la imágen:
Código:
Me.BackgroundImageLayout = ImageLayout.Stretch

Saludos!
« Última modificación: 31 Mayo 2013, 16:28 pm 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 #133 en: 31 Mayo 2013, 16:28 pm »

Miedo me da ese código, no sé si querrás publicar eso, te lo digo más que nada porque no le veo sentido ni utilidad cuando existe una propiedad para redimensionar la imágen:
Código:
Me.BackgroundImageLayout = ImageLayout.Stretch

Seriusly? xD Y yo buscando como un negro 20000 código por Interné...
En línea


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

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #134 en: 31 Mayo 2013, 16:33 pm »

Seriusly? xD Y yo buscando como un negro 20000 código por Interné...

Claro, si alguna vez me hicieras caso y leyeras el nombre y la descripción de cada propiedad, ni 3 minutos lleva mirarse las propiedades de un Form, aparte de aprender un poco más no perderías tiempo buscando códigos tontos.
...Pero lo que me hace gracia es que alguien haya gastado tiempo escribiendo ese código que comentas, me imagino que también lo habrá escrito sin saber que existia dicha propiedad, el colmo xD.

En fín, publica lo que quieras de todas formas he?, pa eso está esta sección.

saludos
« Última modificación: 31 Mayo 2013, 16:35 pm 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 #135 en: 31 Mayo 2013, 16:47 pm »

Pos yasta aquí están los codes  :rolleyes:

Cambiar imagen al pasar el Mouse en VB.NET (Google indexando) :laugh:

Cita de: Seazoux
Código
  1.    Private Sub picMini_MouseEnter(sender As Object, e As EventArgs) Handles picMini.MouseEnter
  2.        sender.Image = Mini_Off
  3.    End Sub
  4.  
  5.    Private Sub picMini_MouseLeave(sender As Object, e As EventArgs) Handles picMini.MouseLeave
  6.        sender.Image = Mini_On
  7.    End Sub

Código
  1.    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.        picMini.Image = Mini_On 'Aqui se carga la que se va a mostrar por defecto
  3.        picMini.BackColor = Color.Transparent 'Por si tiene transparencias la imagen

Código
  1.    Dim Mini_Off As Image = Image.FromFile(".\Art\Buttons\Mini_Off.png")
  2.    Dim Mini_On As Image = Image.FromFile(".\Art\Buttons\Mini_On.png")


Adaptar imagen de Fondo al Form VB.NET (Para los que seáis unos negros y no sepáis las propiedades un Form como yo :laugh: :laugh: )

Código
  1.  
  2.    Dim Fondo As Image = Image.FromFile(".\Art\fondo.jpg")
  3.  
  4.        Dim ancho As String = Me.Width
  5.        Dim alto As String = Me.Height
  6.  
  7. Dim bm_source As Bitmap = New Bitmap(Fondo)
  8.        Dim bm_dest As New Bitmap(CInt(ancho), CInt(alto))
  9.        Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)  
  10.        gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1)
  11.        Me.BackgroundImage = bm_dest

Un saludo.  ;D
« Última modificación: 31 Mayo 2013, 16:54 pm por Seazoux » En línea


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

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #136 en: 31 Mayo 2013, 16:58 pm »

[FastColoredTextBox] Scroll Text

Scrollea hasta el final del texto y posiciona el cursor del teclado en el último caracter.

PD: Se requiere el control extendido FastColoredTextbox.



Código
  1. #Region " [FastColoredTextBox] Scroll Text "
  2.  
  3.    ' FastColoredTextBox] Scroll Text
  4.    '
  5.    ' // By Elektro H@cker
  6.  
  7.    Private Sub FastColoredTextBox1_TextChanged(sender As Object, e As FastColoredTextBoxNS.TextChangedEventArgs) _
  8.        Handles FastColoredTextBox1.TextChangedDelayed
  9.  
  10.        sender.ScrollLeft()
  11.        sender.Navigate(sender.Lines.Count - 1) ' Scroll to down
  12.        sender.SelectionStart = sender.Text.Length ' Set the keyboard cursor position
  13.  
  14.    End Sub
  15.  
  16. #End Region
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #137 en: 31 Mayo 2013, 19:48 pm »

Convierte código Hexadecimal a número Win32Hex

Código
  1. #Region " Hex To Win32Hex "
  2.  
  3.    ' [ Hex To Win32Hex Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples:
  8.    ' MsgBox(Hex_To_Win32Hex("FF4"))   ' Result: &HFF4
  9.    ' MsgBox(Hex_To_Win32Hex("0xFF4")) ' Result: &HFF4
  10.    ' Dim Number As Int32 = Hex_To_Win32Hex("0xFF4") ' Result: 4084
  11.  
  12.    Private Function Hex_To_Win32Hex(ByVal Hex As String) As String
  13.        If Hex.ToLower.StartsWith("0x") Then Hex = Hex.Substring(2, Hex.Length - 2)
  14.        Return "&H" & Hex
  15.    End Function
  16.  
  17. #End Region
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Librería de Snippets !! (Posteen aquí sus snippets)
« Respuesta #138 en: 31 Mayo 2013, 20:33 pm »

- Detect mouse wheel direction.

Comprueba en que dirección se movió la rueda del mouse.

Código
  1.    Private Sub Form_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseWheel
  2.  
  3.        Select Case Math.Sign(e.Delta)
  4.            Case Is < 0
  5.                MsgBox("MouseWheel Down")
  6.            Case Is > 0
  7.                MsgBox("MouseWheel Up")
  8.        End Select
  9.  
  10.    End Sub





Comprueba en que dirección se movió la rueda del mouse.
...Lo mismo que antes pero usando los mensajes de Windows:


Código
  1.    Public Shared Mouse_Have_Wheel As Boolean = My.Computer.Mouse.WheelExists
  2.  
  3.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  4.        Application.AddMessageFilter(New MouseWheelMessageFilter())
  5.    End Sub
  6.  
  7.    Public Class MouseWheelMessageFilter
  8.        Implements IMessageFilter
  9.  
  10.        Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
  11.  
  12.            If Mouse_Have_Wheel Then
  13.  
  14.                If m.Msg = &H20A Then
  15.  
  16.                    If Form.ActiveForm IsNot Nothing Then
  17.  
  18.                        Try ' "Try" solves too fast wheeling.
  19.  
  20.                            Dim delta As Integer = m.WParam.ToInt32() >> 16
  21.  
  22.                            If delta > 0 Then
  23.                                MsgBox("MouseWheel Up")
  24.                            Else
  25.                                MsgBox("MouseWheel Down")
  26.                            End If
  27.  
  28.                        Catch : End Try
  29.  
  30.                    End If
  31.  
  32.                    Return True
  33.                End If
  34.  
  35.            End If
  36.  
  37.            Return False
  38.  
  39.        End Function
  40.  
  41.    End Class





Ejemplo de como modificar la fuente de texto actual de un control:

Código
  1. Me.Font = New Font("Lucida Console", 16, FontStyle.Regular, GraphicsUnit.Point)
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 #139 en: 31 Mayo 2013, 20:41 pm »

Anda esto me viene bien para mi topic de scroll de imagenes, que casualidad  ;-) :laugh:
En línea


Interesados hablad por Discord.
Páginas: 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ... 59 Ir Arriba Respuesta Imprimir 

Ir a:  

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