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

 

 


Tema destacado:


  Mostrar Temas
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12 13 14 15 16 17
81  Programación / Programación General / [SRC] [Delphi] Números perfectos [by *PsYkE1*] en: 26 Agosto 2010, 16:48 pm
HOla, con esta sencilla funcion mia averiguo los numeros perfectos :D

Código
  1. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  2. (* Function : IsPerfectNumber                      *)
  3. (* Author   : *PsYkE1*                             *)
  4. (* Mail     : vbpsyke1@mixmail.com                 *)
  5. (* Date     : 24/8/10                              *)
  6. (* Purpose  : Check if number is a perfect number  *)
  7. (* Visit    : http://foro.rthacker.net/            *)
  8. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  9.  
  10. function IsPerfectNumber(lNumber:Integer):Boolean;
  11. var
  12.  i : Integer;
  13.  x : Integer;
  14. begin
  15.  I := 0;
  16.  Result := false;
  17.  if lnumber > 0 then
  18.    begin
  19.      for x := 1 to lnumber - 1 do
  20.        begin
  21.          if (lnumber mod x) = 0 then
  22.             i := i + x;
  23.        end;
  24.      if i = lnumber then
  25.       Result := true;
  26.    end;
  27. end;

Ejemplo:
Código
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.  n:integer;
  4.  s:String;
  5. begin
  6.  n := 6;
  7.  str(n,s);
  8.  if IsPerfectNumber(n) = true then
  9.     edit1.Text:= 'El ' + s + ' es un numero perfecto';
  10. end;
  11.  
  12. end.

DoEvents¡! :P
82  Programación / Programación General / [DUDA SENCILLA] DELPHI en: 25 Agosto 2010, 22:27 pm
Porque no funcionan ninguno de estos codigos?
Aviso que no tengo ni idea de Delphi
Code1:
Código
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3. a:integer;
  4. b:integer;
  5. begin
  6.    a:=4;
  7.    b:=4;
  8.    if a=b then
  9.      edit1.Text:= 'hola';
  10. end.
Code2:
Código
  1. function DD(s:string):string;
  2. begin
  3.  result:= s + s + s
  4. end;
  5. /////////////////////////////////////////////////////
  6. procedure TForm1.FormCreate(Sender: TObject);
  7. var
  8. a:string;
  9. begin
  10.    a:='hhh';
  11.    if a = dd('h') then
  12.      edit1.Text:= 'hola';
  13. end.

Gracias!

DoEvents¡! :P
83  Media / Multimedia / Busco Música [AYUDA] en: 24 Agosto 2010, 20:57 pm
Hola, buscaba musica sinfonica, potente, con coros...
Buff.. :-\
Me explico fatal, algo de este estilo:


Gracias ;)

DoEvents¡! :P
84  Foros Generales / Foro Libre / Clases de informatica [HUMOR] en: 23 Agosto 2010, 21:46 pm

Jaaaaaaaaaajajajajajajaj  :laugh: :laugh:

DoEvents¡! :P
85  Programación / Programación General / [SRC] [Delphi] Text_Beetwen_Words [by *PsYkE1*] en: 23 Agosto 2010, 18:37 pm
Hola, me he pasado a Delphi hace dos dias y he pasado esta funcion que tenia hecha en VB6...  :P

http://foro.rthacker.net/programacion-visual-basic/%28src%29-%28funcion%29-text_between_words-%28by-*psyke1*%29/

Código
  1. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  2. (* Function : Text_Beetwen_Words                   *)
  3. (* Author   : *PsYkE1*                             *)
  4. (* Mail     : vbpsyke1@mixmail.com                 *)
  5. (* Date     : 24/8/10                              *)
  6. (* Purpose  : Returns text which is beetwen        *)
  7. (*            two words.                           *)
  8. (* Visit    : http://foro.rthacker.net/            *)
  9. (* * * * * * * * * * * * * * * * * * * * * * * * * *)
  10.  
  11. function InStr(iStart: integer; sText: string; sWord: string): integer;
  12. begin
  13. Result := Pos(sWord,Copy(sText,iStart,Length(sText) - (iStart - 1)));
  14. end;
  15.  
  16. function Text_Beetwen_Words(sTextToAnalyze:String ; sStartWord:String ; sEndWord:string): String;
  17. var
  18.  iPosition1  : Integer;
  19.  iPosition2  : Integer;
  20.  iStart      : Integer;
  21. begin
  22.     iPosition1 := Instr(1,sTextToAnalyze,sStartWord);
  23.     if iPosition1 > 0 then
  24.      begin
  25.        iStart := (iPosition1 + Length(sStartWord));
  26.        iPosition2 := Instr(iStart,sTextToAnalyze,sEndWord);
  27.      end
  28.     else
  29.      exit;
  30.     if iPosition2 > 0 then
  31.      Result := Copy(sTextToAnalyze,iStart,iPosition2 -1);
  32. end;

Un ejemplo:
Código
  1. procedure TForm1.FormCreate(Sender: TObject);
  2.    begin
  3.      (* añade un textbox *)
  4.    edit1.Text:= text_beetwen_words('Hoy estoy muy aburrido','Hoy ',' aburrido');
  5.    end;
  6.  
  7. end.

Devuelve esto:
Citar
estoy muy

DoEvents¡! :P
86  Programación / Programación Visual Basic / [SRC] cCollectionEx.cls en: 20 Agosto 2010, 13:36 pm
¿Todavía sigues usando Collections? :¬¬
¡¡Ahora lo que se lleva es cCollectionEx.cls!! :laugh:



Propiedades:

Add
Código
  1. Add(ByRef Item As Variant, Optional ByVal Index As Long)
¿A qué has adivinado que hace? :laugh: pero incluyo la opcion de insertarlo en un Index especifico.

Contains
Código
  1. Contains(ByRef Item As Variant, Optional ByVal StartIndex As Long = 1)
Sirve para comprbar si un Item ya esta contenido dentro de nuestra cCollectionEx, tambien puedes empezar a buscarlo desde un Index especifico.

Count

Código
  1. Count()
Devuelve la cantidad de Items almacenados.

Item
Código
  1. Item(ByVal Index As Long)
Indica el contenido de in Item en concreto a partir de su Index.

DeleteItem
Código
  1. DeleteItem(ByVal Index As Long)
Borra un Item determinado a partir de el Index ingresado.

SwapItem
Código
  1. SwapItem(ByVal ActualIndex As Long, ByVal DestinationIndex As Long)
Intercambia dos Items.

Sorted ;)
Código
  1. Sorted(Optional ByVal Order As EnuListOrder = DecendentOrder) ' by BlackZeroX
  2.  
Ordena la cCollectionEx alfanumericamente y ademas puedes indicar el orden [descendente/ascendente].

Reverse
Código
  1. Reverse()
Invierte la posicion del contenido de cCollectionEx.

Clear
Código
  1. Clear()
Borra el contenido de cCollectionEx.



Aquí la clase:
Código
  1. Option Explicit
  2. Option Base 1
  3. '=====================================================================
  4. ' º Class         : cCollectionEx.cls
  5. ' º Author        : Psyke1
  6. ' º Mail          : vbpsyke1@mixmail.com
  7. ' º Date          : 17/8/10
  8. ' º Last modified : 01/06/12
  9. ' º Purpose       : Replace and improve the vb6 Collection Object
  10. ' º Greets        : BlackZer0x & xkiz
  11. ' º Sorted by BlackZer0x :
  12. '           http://bit.ly/M5zCKw
  13. ' º Recommended Websites :
  14. '           http://foro.h-sec.org/
  15. '           http://www.frogcheat.com.ar/
  16. '           http://infrangelux.sytes.net/
  17. '=====================================================================
  18. Private Declare Sub RtlMoveMemory Lib "ntdll.dll" (ByVal pDest As Long, ByVal pSrc As Long, ByVal lBytes As Long)
  19.  
  20. Public Enum EnuListOrder
  21.    AcendetOrder = 0
  22.    DecendentOrder = 1
  23. End Enum
  24.  
  25. Private vColl()                             As Variant
  26. Private lCount                              As Long
  27. Private lLimit                              As Long
  28. Private ReverseMode                         As Boolean
  29.  
  30.  
  31. '// Inizialice the matrix.
  32. Private Sub Class_Initialize()
  33.    lLimit = &H400
  34.    ReDim vColl(lLimit)
  35. End Sub
  36.  
  37. '// It returns the number of items contained in the matrix.
  38. Public Property Get Count() As Long
  39.    Count = lCount
  40. End Property
  41.  
  42. '// It returns an specific item form there index.
  43. Public Property Get Item(ByVal Index As Long) As Variant
  44.    If ReverseMode Then FixIndex Index
  45.    Item = vColl(Index)
  46. End Property
  47.  
  48. '// It returns the index of an item if exists in the matrix.
  49. Public Function Contains(ByRef Item As Variant, Optional ByVal StartIndex As Long = 1) As Long
  50. Dim Q                                       As Long
  51.  
  52.    If (StartIndex < lCount) And (StartIndex > 0) Then
  53.        For Q = StartIndex To lCount
  54.            If vColl(Q) = Item Then
  55.                If ReverseMode Then
  56.                    Contains = lCount + 1 - Q
  57.                Else
  58.                    Contains = Q
  59.                End If
  60.  
  61.                Exit Function
  62.            End If
  63.        Next
  64.    End If
  65. End Function
  66.  
  67. '// Add a new item to the cCollection, if you specify the index so you can add in a particular position.
  68. Public Function Add(ByRef Item As Variant, Optional ByVal Index As Long) As Long
  69.    If IsObject(Item) = False Then
  70.        If ReverseMode Then FixIndex Index
  71.  
  72.        lCount = lCount + 1
  73.  
  74.        If lCount > lLimit Then
  75.           lLimit = lLimit + lLimit
  76.           ReDim Preserve vColl(lLimit)
  77.        End If
  78.  
  79.        If Index > 0 And Index <= lCount Then
  80.            RtlMoveMemory VarPtr(vColl(Index + 1)), VarPtr(vColl(Index)), (lCount - Index) * 16&
  81.            Add = Index
  82.        Else
  83.            Add = lCount
  84.        End If
  85.  
  86.        vColl(Add) = Item
  87.    End If
  88. End Function
  89.  
  90. '// Delete an specific item from its index.
  91. Public Function DeleteItem(ByVal Index As Long) As Long
  92.    If (Index > 0) And (Index <= lCount) Then
  93.        If ReverseMode Then FixIndex Index
  94.  
  95.        If (Index < lCount) Then
  96.            RtlMoveMemory VarPtr(vColl(Index)), VarPtr(vColl(Index + 1)), (lCount - Index) * 16&
  97.        End If
  98.  
  99.        If (lCount - 1) > 0 Then
  100.            lCount = lCount - 1
  101.        Else
  102.            Clear
  103.        End If
  104.  
  105.        DeleteItem = Index
  106.    End If
  107. End Function
  108.  
  109. '// Swaps the contents of two items entering its index.
  110. Public Function SwapItem(ByVal FirstIndex As Long, ByVal DestIndex As Long) As Long
  111. Dim vSwap                                   As Variant
  112.  
  113.    If (FirstIndex <= lCount And FirstIndex > 0) And (DestIndex <= lCount And DestIndex > 0) And (FirstIndex <> DestIndex) Then
  114.        If ReverseMode Then
  115.            FixIndex FirstIndex
  116.            FixIndex DestinationIndex
  117.        End If
  118.  
  119.        vSwap = vColl(FirstIndex)
  120.        vColl(FirstIndex) = vColl(DestIndex)
  121.        vColl(DestIndex) = vSwap
  122.        SwapItem = DestIndex
  123.    End If
  124. End Function
  125.  
  126. '// Reverse all Items.
  127. Public Sub Reverse()
  128.    ReverseMode = Not ReverseMode
  129. End Sub
  130.  
  131. '// Deletes all items.
  132. Public Sub Clear()
  133.    Erase vColl
  134.    lCount = 0&
  135. End Sub
  136.  
  137. '// To simplify code, it's to reverse the index.
  138. Private Sub FixIndex(ByRef lIndex As Long)
  139.    lIndex = lCount + 1 - lIndex
  140. End Sub
  141.  
  142. '// Sort items alphanumerically and you can specify the order too [desdendent or ascendent].
  143. Public Sub Sorted(Optional ByVal Order As EnuListOrder = DecendentOrder)
  144.    If (Not (vColl)) = -1 Then Exit Sub
  145.    Call QSort(1, lCount, Order)
  146. End Sub
  147.  
  148. Private Sub QSort(ByVal lb As Long, ByVal ub As Long, Optional ByVal Order As EnuListOrder = DecendentOrder)
  149. Dim k                                As Long
  150.    If lb < ub Then
  151.        Call PreSort(lb, ub, k, Order)
  152.        Call QSort(lb, k - 1, Order)
  153.        Call QSort(k + 1, ub, Order)
  154.    End If
  155. End Sub
  156.  
  157. Private Sub PreSort(ByVal lb As Long, ByVal ub As Long, ByRef k As Long, Optional ByVal Order As EnuListOrder = DecendentOrder)
  158. Dim i                               As Long
  159. Dim j                               As Long
  160. Dim il                              As Long
  161. Dim jl                              As Long
  162.    il = 0: jl = -1
  163.    i = lb: j = ub
  164.    While i < j
  165.        If Order = DecendentOrder Then
  166.            If IsNumeric(vColl(i)) And IsNumeric(vColl(j)) Then
  167.                If Val(vColl(i)) > Val(vColl(j)) Then Call AuxOrden(i, j, il, jl)
  168.            Else
  169.                If vColl(i) > vColl(j) Then Call AuxOrden(i, j, il, jl)
  170.            End If
  171.        Else
  172.            If IsNumeric(vColl(i)) And IsNumeric(vColl(j)) Then
  173.                If Val(vColl(i)) < Val(vColl(j)) Then Call AuxOrden(i, j, il, jl)
  174.            Else
  175.                If vColl(i) < vColl(j) Then Call AuxOrden(i, j, il, jl)
  176.            End If
  177.        End If
  178.        i = i + il
  179.        j = j + jl
  180.    Wend
  181.    k = i
  182. End Sub
  183.  
  184. Private Sub AuxOrden(ByVal i As Long, ByVal j As Long, ByVal il As Long, ByVal jl As Long)
  185. Dim c                               As String
  186. Dim c2                              As Long
  187.    c = vColl(j)
  188.    vColl(j) = vColl(i)
  189.    vColl(i) = c
  190.    c2 = il
  191.    il = -jl
  192.    jl = -c2
  193. End Sub
  194.  



¿No crees que sea más rapido?  :-(

Pon esto en un form, añade la clase y compílalo:
Código
  1. Option Explicit
  2. Private Declare Function GetTickCount Lib "Kernel32" () As Long
  3.  
  4. ' Con Collection
  5. Public Function Check_Lucky_Number(ByVal lNumber As Long) As Boolean
  6.    Dim cTemp                   As New Collection
  7.    Dim NextElim                As Long
  8.    Dim m                       As Long
  9.    Dim x                       As Long
  10.  
  11.    If lNumber = 1 Or lNumber = 3 Then
  12.        GoTo IsLucky
  13.    ElseIf (lNumber > 1) And (lNumber Mod 2 <> 0) Then
  14.        With cTemp
  15.            For x = 1 To lNumber Step 2
  16.                .Add x
  17.            Next
  18.            NextElim = 3: m = 2
  19.            Do
  20.                x = NextElim
  21.                Do While x <= .Count
  22.                    .Remove (x)
  23.                    x = x + (NextElim - 1)
  24.                Loop
  25.                If .Item(.Count) = lNumber Then
  26.                    m = m + 1
  27.                    NextElim = .Item(m)
  28.                Else
  29.                    Exit Function
  30.                End If
  31.            Loop While Not NextElim > .Count
  32.        End With
  33. IsLucky: Check_Lucky_Number = True
  34.    End If
  35. End Function
  36.  
  37. ' Con cCollectionEx
  38. Public Function Check_Lucky_Number2(ByVal lNumber As Long) As Boolean
  39.    Dim cTemp                   As New cCollectionEx
  40.    Dim NextElim                As Long
  41.    Dim m                       As Long
  42.    Dim x                       As Long
  43.  
  44.    If lNumber = 1 Or lNumber = 3 Then
  45.        GoTo IsLucky
  46.    ElseIf (lNumber > 1) And (lNumber Mod 2 <> 0) Then
  47.        With cTemp
  48.            For x = 1 To lNumber Step 2
  49.                .Add x
  50.            Next
  51.            NextElim = 3: m = 2
  52.            Do
  53.                x = NextElim
  54.                Do While x <= .Count
  55.                    Call .DeleteItem(x)
  56.                    x = x + (NextElim - 1)
  57.                Loop
  58.                If .Item(.Count) = lNumber Then
  59.                    m = m + 1
  60.                    NextElim = .Item(m)
  61.                Else
  62.                    Exit Function
  63.                End If
  64.            Loop While Not NextElim > .Count
  65.        End With
  66. IsLucky: Check_Lucky_Number2 = True
  67.    End If
  68. End Function
  69.  
  70. Private Sub Form_Load()
  71.    Dim T1          As Long
  72.    Dim T2          As Long
  73.    Dim x           As Long
  74.    Dim sResult     As String
  75.  
  76.    If App.LogMode = 0 Then
  77.        MsgBox "Prueba con proyecto compilado¡!", vbCritical
  78.        End
  79.    End If
  80.  
  81.    T1 = GetTickCount
  82.    For x = 5000 To 7000
  83.        If Check_Lucky_Number(x) Then
  84.            sResult = sResult & x & " "
  85.        End If
  86.    Next
  87.    T2 = GetTickCount
  88.    MsgBox "With Collection -> " & (T2 - T1)
  89.    MsgBox sResult
  90.  
  91.    '*************************************************************************
  92.    sResult = ""
  93.    '*************************************************************************
  94.  
  95.    T1 = GetTickCount
  96.    For x = 5000 To 7000
  97.        If Check_Lucky_Number2(x) Then
  98.            sResult = sResult & x & " "
  99.        End If
  100.    Next
  101.    T2 = GetTickCount
  102.    MsgBox "With cCollectionEx -> " & (T2 - T1)
  103.  
  104.    MsgBox sResult
  105. End Sub

La diferencia suele oscilar entre los 2500/3000 ms  ::)
EDIT: He mejorado la clase, ahora será bastante mayor.

DoEvents¡! :P
87  Foros Generales / Foro Libre / Dali :D en: 15 Agosto 2010, 01:00 am
Os dejo unas obras de mi pintor favorito:
Salvador Dalí






DoEvents¡! :P
88  Seguridad Informática / Seguridad / Windows Seven y autorun.inf en: 10 Agosto 2010, 21:53 pm
Hola, según esto:
http://www.genbeta.com/sistemas-operativos/adios-a-autoruninf-en-windows-7

Ya no tienen nada que hacer los virus que se propagan por USB?¿  :huh:

DoEvents¡! :P
89  Foros Generales / Sugerencias y dudas sobre el Foro / Problemas IRC elhacker.net en: 10 Agosto 2010, 21:51 pm
Cada vez que entro en el IRC no tengo voz, aviso a un moderador o a un admin, consigo voz, pero me conecto por la tarde y ya no tengo... :-\
Que es lo que pasa?¿ :huh:

PD: Obviamente me identifico, y no me da ningun error...

Gracias! :)

DoEvents¡! :P
90  Programación / Programación Visual Basic / Recortar número en: 10 Agosto 2010, 02:59 am
Quizas sea muy simple, pero en fin:

Imaginemos que tengo esto:

Código
  1. Dim a As Integer
  2. Dim b as Integer
  3.  
  4. a = 2345
  5. b = CInt(Right$(CStr(a),2))
  6.  
  7. msgbox a
  8. msgbox b

¿Como obtengo el mismo resultado, peeeeeero sin utilizar Right$()? :huh:

Gracias! ;D

DoEvents¡! :P
Páginas: 1 2 3 4 5 6 7 8 [9] 10 11 12 13 14 15 16 17
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines