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 ... 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 [808] 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 ... 1254
8071  Programación / .NET (C#, VB.NET, ASP) / Re: Cómo obtener datos de un form principal a uno secundario en .NET en: 10 Noviembre 2013, 19:21 pm
Declara una property como te ha indicado el compañero @Hadess_inf

Solo es necesario que modifiques el código del formulario que contiene el primer TextBox:

Código
  1. Public Class Form1
  2.  
  3.    Public Property TB_text As String
  4.        Get
  5.            Return Me.TB.Text
  6.        End Get
  7.        Set(ByVal str As String)
  8.            Form2.TB.Text = str
  9.        End Set
  10.    End Property
  11.  
  12.    Private Sub TB_TextChanged(sender As Object, e As EventArgs) _
  13.    Handles TB.TextChanged
  14.        Me.TB_text = sender.text
  15.    End Sub
  16.  
  17.    Private Shadows Sub Load() Handles MyBase.Load
  18.        Me.TB.Text = "Hello World!"
  19.        Form2.Show()
  20.    End Sub
  21.  
  22. End Class

La intención es separar un poco los datos, de la UI, siempre hay que tener los buenos hábitos en mente... (aunque esto no sea WPF), pero si lo prefieres diréctamente puedes ahorrarte la propiedad y utilizar el evento OnTextChanged para interactuar con el Textbox secundario:

Código
  1. Public Class Form1
  2.  
  3.    Private Shadows Sub Load() Handles MyBase.Load
  4.        Form2.Show()
  5.        TB.Text = "Hello World!"
  6.    End Sub
  7.  
  8.    Private Sub TB_TextChanged(sender As Object, e As EventArgs) _
  9.    Handles TB.TextChanged
  10.        Form2.TB.Text = sender.text
  11.    End Sub
  12.  
  13. End Class

Saludos
8072  Programación / .NET (C#, VB.NET, ASP) / Re: Enviar y Recibir SMS desde la PC con vb.NET en: 10 Noviembre 2013, 19:00 pm
Aquí tienes lo necesario:
.NET Phone Communication Library Part IV - Receive SMS

Plus:
.NET Phone Communication Library Part I - Retrieve Phone Settings

PD: El resto de artículos parece que han sido eliminados por antiguedad.

Saludos
8073  Programación / .NET (C#, VB.NET, ASP) / Re: [C#] [VB.NET] Enums con valores duplicados en: 10 Noviembre 2013, 18:45 pm
@Keyen Night gracias

Cierro el tema.
8074  Programación / .NET (C#, VB.NET, ASP) / Re: Pregunta tonta ? como cambiar icono en visual net 2010 ejecutables y formularios en: 1 Noviembre 2013, 15:20 pm
¿Los iconos los tienes en formato ICO o son en formato PNG?,  si te fijas el diálogo está filtrado para mostrar sólamente iconos en formato ICO, no PNG...

(no quiero pensar que reálmente no te reconoce los iconos ICO... es casi imposible, segúramente la causa sea lo que te acabo de decir)

De todas formas te digo como hacerlo de forma manual...

Para el icono del exe, en el archivo .vbproj de tu solución añade esto:
Código:
  <PropertyGroup>
    <ApplicationIcon>C:\ruta del icono.ICO</ApplicationIcon>
  </PropertyGroup>

Y para cambiar el icono del formulario...
Código
  1.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.  
  3.        Dim bmp As Bitmap = Bitmap.FromFile("C:\ruta del icono.ICO")
  4.  
  5.        Me.Icon = System.Drawing.Icon.FromHandle(bmp.GetHicon())
  6.  
  7.    End Sub

Saludos
8075  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 1 Noviembre 2013, 14:56 pm
Dado un número, devuelve el valor más próximo de un Enum.

Código
  1.    #Region " Get Nearest Enum Value "
  2.  
  3.       ' [ Get Nearest Enum Value ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       '
  9.       ' Enum Bitrate As Short : kbps_128 = 128 : kbps_192 = 192 : kbps_256 = 256 : kbps_320 = 320 : End Enum
  10.       ' MsgBox(Get_Nearest_Enum_Value(Of Bitrate)(133).ToString) ' Result: kbps_128
  11.       ' MsgBox(Get_Nearest_Enum_Value(Of KnownColor)(1000)) ' Result: 174
  12.  
  13.    Private Function Get_Nearest_Enum_Value(Of T)(ByVal value As Long) As T
  14.  
  15.        Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  16.                                               Cast(Of Object).
  17.                                               OrderBy(Function(br) Math.Abs(value - br)).
  18.                                               First)
  19.  
  20.    End Function
  21.  
  22.    #End Region



Dado un número, devuelve el valor próximo más bajo de un Enum.

Código
  1.    #Region " Get Nearest Lower Enum Value "
  2.  
  3.       ' [ Get Nearest Lower Enum Value ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       '
  9.       ' Enum Bitrate As Short : kbps_128 = 128 : kbps_192 = 192 : kbps_256 = 256 : kbps_320 = 320 : End Enum
  10.       ' MsgBox(Get_Nearest_Lower_Enum_Value(Of Bitrate)(190).ToString) ' Result: kbps_128
  11.       ' MsgBox(Get_Nearest_Lower_Enum_Value(Of Bitrate)(196).ToString) ' Result: kbps_192
  12.  
  13.    Private Function Get_Nearest_Lower_Enum_Value(Of T)(ByVal value As Integer) As T
  14.  
  15.        Select Case value
  16.  
  17.            Case Is < [Enum].GetValues(GetType(T)).Cast(Of Object).First
  18.                Return Nothing
  19.  
  20.            Case Else
  21.                Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  22.                                                       Cast(Of Object)().
  23.                                                       Where(Function(enum_value) enum_value <= value).
  24.                                                       Last)
  25.        End Select
  26.  
  27.    End Function
  28.  
  29.    #End Region




Dado un número, devuelve el valor próximo más alto de un Enum.

Código
  1.    #Region " Get Nearest Higher Enum Value "
  2.  
  3.       ' [ Get Nearest Higher Enum Value ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       '
  9.       ' Enum Bitrate As Short : kbps_128 = 128 : kbps_192 = 192 : kbps_256 = 256 : kbps_320 = 320 : End Enum
  10.       ' MsgBox(Get_Nearest_Higher_Enum_Value(Of Bitrate)(196).ToString) ' Result: kbps_256
  11.       ' MsgBox(Get_Nearest_Higher_Enum_Value(Of KnownColor)(1000)) ' Result: 0
  12.  
  13.    Private Function Get_Nearest_Higher_Enum_Value(Of T)(ByVal value As Integer) As T
  14.  
  15.        Select Case value
  16.  
  17.            Case Is > [Enum].GetValues(GetType(T)).Cast(Of Object).Last
  18.                Return Nothing
  19.  
  20.            Case Else
  21.  
  22.                Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  23.                                                       Cast(Of Object).
  24.                                                       Where(Function(enum_value) enum_value >= value).
  25.                                                       FirstOrDefault)
  26.        End Select
  27.  
  28.    End Function
  29.  
  30.    #End Region

EDITO:

Aquí todos juntos:

Código
  1.    #Region " Get Nearest Enum Value "
  2.  
  3.        ' [ Get Nearest Enum Value ]
  4.        '
  5.        ' // By Elektro H@cker
  6.        '
  7.        ' Examples :
  8.        '
  9.        ' MsgBox(Get_Nearest_Enum_Value(Of Bitrate)(133, Enum_Direction.Nearest).ToString) ' Result: kbps_128
  10.        ' MsgBox(Get_Nearest_Enum_Value(Of KnownColor)(1000, Enum_Direction.Nearest)) ' Result: 174
  11.        '
  12.        ' MsgBox(Get_Nearest_Enum_Value(Of Bitrate)(190, Enum_Direction.Down).ToString) ' Result: kbps_128
  13.        ' MsgBox(Get_Nearest_Enum_Value(Of KnownColor)(-1, Enum_Direction.Down).ToString) ' Result: 0
  14.        '
  15.        ' MsgBox(Get_Nearest_Enum_Value(Of Bitrate)(196, Enum_Direction.Up).ToString) ' Result: kbps_256
  16.        ' MsgBox(Get_Nearest_Enum_Value(Of KnownColor)(1000, Enum_Direction.Up)) ' Result: 0
  17.  
  18.    Private Enum Enum_Direction As Short
  19.        Down = 1
  20.        Up = 2
  21.        Nearest = 0
  22.    End Enum
  23.  
  24.    Private Function Get_Nearest_Enum_Value(Of T)(ByVal value As Long, _
  25.                                                  Optional ByVal direction As Enum_Direction = Enum_Direction.Nearest) As T
  26.  
  27.        Select Case direction
  28.  
  29.            Case Enum_Direction.Nearest ' Return nearest Enum value
  30.                Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  31.                                                       Cast(Of Object).
  32.                                                       OrderBy(Function(br) Math.Abs(value - br)).
  33.                                                       First)
  34.  
  35.            Case Enum_Direction.Down ' Return nearest lower Enum value
  36.                If value < [Enum].GetValues(GetType(T)).Cast(Of Object).First Then
  37.                    Return Nothing
  38.                Else
  39.                    Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  40.                                                           Cast(Of Object)().
  41.                                                           Where(Function(enum_value) enum_value <= value).
  42.                                                           Last)
  43.                End If
  44.  
  45.            Case Enum_Direction.Up ' Return nearest higher Enum value
  46.                If value > [Enum].GetValues(GetType(T)).Cast(Of Object).Last Then
  47.                    Return Nothing
  48.                Else
  49.                    Return [Enum].Parse(GetType(T), [Enum].GetValues(GetType(T)).
  50.                                                           Cast(Of Object).
  51.                                                           Where(Function(enum_value) enum_value >= value).
  52.                                                           FirstOrDefault)
  53.                End If
  54.  
  55.        End Select
  56.  
  57.    End Function
  58.  
  59.    #End Region
8076  Programación / .NET (C#, VB.NET, ASP) / Re: Como eliminar resultados numericos en un variable o Array ? en: 29 Octubre 2013, 14:52 pm
Vamos Luis te lo he dado todo hecho, no es dificil adaptarlo, te falta poco.

En tu último código no has declarado el valor máximo
Citar
Código
  1. Dim maximum As Short = 99

Solo te falta eso y copiar esto otro:
Citar
Código
  1.        For Each Number As Integer In Result1
  2.  
  3.           TextBoxes(TextBoxCount).Text = _
  4.               If(Not Number > maximum, _
  5.                  CStr(Number), _
  6.                  CStr(maximum))
  7.  
  8.           Threading.Interlocked.Increment(TextBoxCount)
  9.  
  10.       Next Number

La verdad es que el búcle no requiere ningún cambio, pero puedes escribirlo de esta otra forma:

Código:
For Each Number As Int32 In Result1

    TextBoxCount += 1

    if not Number > maximum then
       TextBoxes(TextBoxCount).Text = cstr(number)
    else
       TextBoxes(TextBoxCount).Text = cstr(maximum)
     end if

 Next Number

Saludos
8077  Programación / Scripting / Re: Error en Bat en: 29 Octubre 2013, 12:07 pm
Los búcles procesan todos los valores que le has dado en su totalidad, por este orden:

Código:
a:1 b:20 c:100 d:1 e:40
a:1 b:20 c:100 d:1 e:50
a:1 b:20 c:100 d:2 e:40
a:1 b:20 c:100 d:2 e:50
a:1 b:20 c:200 d:1 e:40
a:1 b:20 c:200 d:1 e:50
a:1 b:20 c:200 d:2 e:40
a:1 b:20 c:200 d:2 e:50
a:1 b:30 c:100 d:1 e:40
a:1 b:30 c:100 d:1 e:50
a:1 b:30 c:100 d:2 e:40
a:1 b:30 c:100 d:2 e:50
a:1 b:30 c:200 d:1 e:40
a:1 b:30 c:200 d:1 e:50
a:1 b:30 c:200 d:2 e:40
a:1 b:30 c:200 d:2 e:50
a:2 b:20 c:100 d:1 e:40
a:2 b:20 c:100 d:1 e:50
a:2 b:20 c:100 d:2 e:40
a:2 b:20 c:100 d:2 e:50
a:2 b:20 c:200 d:1 e:40
a:2 b:20 c:200 d:1 e:50
a:2 b:20 c:200 d:2 e:40
a:2 b:20 c:200 d:2 e:50
a:2 b:30 c:100 d:1 e:40
a:2 b:30 c:100 d:1 e:50
a:2 b:30 c:100 d:2 e:40
a:2 b:30 c:100 d:2 e:50
a:2 b:30 c:200 d:1 e:40
a:2 b:30 c:200 d:1 e:50
a:2 b:30 c:200 d:2 e:40
a:2 b:30 c:200 d:2 e:50

¿Que intentas hacer?, ¿Cual debería ser el resultado esperado?.

Saludos!
8078  Sistemas Operativos / Windows / Re: Problema con asosiacion de archivos en Win 7 en: 29 Octubre 2013, 12:01 pm
Hola, ¿debemos adivinar de que reproductor hablas?.

En el valor por defecto de la clave:
Código:
HKEY_CLASSES_ROOT\.dll
...Encontrarás la asociación.

Ejemplo:

Código:
HKEY_CLASSES_ROOT\.dll "default value=mediaplayer.dll"

Código:
HKEY_CLASSES_ROOT\mediaplayer.dll

Si no se encuentra ahí, entonces está en la clave SystemFileAssociations:

Código:
HKCR\SystemFileAssociations\.dll
HKLM\SystemFileAssociations\.dll

Saludos.
8079  Programación / Scripting / Re: Script copia pega carpetascon rutas relativas en: 29 Octubre 2013, 11:52 am
En WindowsXP tienes que usar el nombre de la carpeta tal cual, Escritorio en castellano, Desktop en Inglés, y no se como será en aleman.

(De todas formas puedes encontrar el nombre correcto en las claves de registro que almacenan las rutas de las carpetas del sistema)

En el resto de Windows posteriores puedes referirte a las User Shell-Folders por su nombre en Inglés:
Código:
%USERPROFILE%\Desktop
-> http://en.wikipedia.org/wiki/Special_folder

Saludos
8080  Informática / Software / Re: Para que sirve y puedo desactivarlo "Intel(R) Management Engine Components" en: 28 Octubre 2013, 19:46 pm
que información me pueden dar y si es recomendable desactivarlo mas no eliminarlo.

Aquí puedes ver que es, para que sirve, si es recomendable desactivarlo, y toda la información adicional que puedas llegar a necesitar...

En serio, ¿tanto cuesta buscar antes de preguntar?.

Un saludo.
Páginas: 1 ... 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 [808] 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines