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

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  random vb6
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: random vb6  (Leído 5,318 veces)
BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: random vb6
« Respuesta #10 en: 23 Enero 2013, 04:46 am »

Código
  1. sub main()
  2.    Dim path as string
  3.    path = "c:\Dir\Dir2\" & TextoAleatorio("a-z", "-", 5, 10) & ".bat" ' Esto genera un texto aleatoria que comprende las letras desde "a" hasta "z" TODAS minusculas segun el codigo asccii con longitud minima de 5 caracteres y 10 como máximo.
  4.    ' Más codigo
  5. end sub
  6.  
  7. Private Sub NormalizePath(ByRef sData As String)
  8.    sData = IIf(Right$(sData, 1) = "\", sData, sData & "\")
  9. End Sub
  10.  
  11. Function TextoAleatorio(StrRango As String, Separador As String, Optional LENTEXTMIN As Long = 1, Optional LENTEXTMAX As Long = -1) As String
  12. Dim spli()                                      As String
  13. Dim i                                           As Double
  14.    If InStr(StrRango, Separador) > 0 Then
  15.        spli = Split(StrRango, Separador)
  16.        LENTEXTMAX = LENTEXTMIN + Int(IIf(LENTEXTMAX = -1, NumeroAleatorio(1, 100), LENTEXTMAX))
  17.        For i = LENTEXTMIN To LENTEXTMAX
  18.            TextoAleatorio = TextoAleatorio & Chr(NumeroAleatorio(Asc(spli(0)), Asc(spli(1))))
  19.        Next i
  20.    End If
  21. End Function
  22.  
  23. Public Function NumeroAleatorio(MinNum As Long, MaxNum As Long) As Long
  24. Dim Tmp                                 As Long
  25.    If MaxNum < MinNum Then: Tmp = MaxNum: MaxNum = MinNum: MinNum = Tmp
  26.    Randomize: NumeroAleatorio = CLng((MinNum - MaxNum + 1) * Rnd + MaxNum)
  27. End Function
  28.  

Dulces Lunas!¡.


« Última modificación: 23 Enero 2013, 04:48 am por BlackZeroX (Astaroth) » En línea

The Dark Shadow is my passion.
Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Random en VB
Programación Visual Basic
Jess_Kapria 4 4,388 Último mensaje 30 Diciembre 2005, 18:54 pm
por c0rrupt_gamer
Random
Scripting
Herzius 4 3,252 Último mensaje 22 Enero 2008, 18:35 pm
por paperas
El Random no es tan Random.
Programación Visual Basic
Freeze. 7 2,816 Último mensaje 16 Septiembre 2008, 21:02 pm
por JineteNegro666
Random Freezes/crashes en Centos 6.4
GNU/Linux
Gotttlieb 3 2,462 Último mensaje 2 Septiembre 2013, 19:06 pm
por Gotttlieb
Duda con Random C#
Programación General
Bob1098 4 3,026 Último mensaje 12 Mayo 2014, 16:40 pm
por Bob1098
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines