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

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


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

Desconectado Desconectado

Mensajes: 20


Ver Perfil
Problemita path
« en: 25 Septiembre 2009, 18:28 pm »

Bue este problemita me ta rompiendo vastantes las %"·&% :xD

este es el codigo

Código
  1. Private Sub Reemplazar_Texto(ByVal El_Archivo As String, _
  2.                            ByVal La_cadena As String, _
  3.                            ByVal Nueva_Cadena As String)
  4.  
  5. On Error GoTo errSub
  6. Dim F As Integer
  7. Dim Contenido As String
  8.  
  9.  
  10.    F = FreeFile
  11.  
  12.    Open El_Archivo For Input As F
  13.  
  14.    Contenido = Input$(LOF(F), #F)
  15.  
  16.    Close #F
  17.  
  18.    Contenido = Replace(Contenido, La_cadena, Nueva_Cadena)
  19.  
  20.  
  21.    F = FreeFile
  22.  
  23.    Open El_Archivo For Output As F
  24.  
  25.    Print #F, Contenido
  26.  
  27.  
  28.    Close #F
  29.  
  30.    MsgBox " Listo!!! ", vbInformation
  31. Exit Sub
  32.  
  33. 'Error
  34.  
  35. errSub:
  36. MsgBox Err.Description, vbCritical
  37. Close
  38. End Sub
  39.  
  40.  
  41. Private Sub Command1_Click()
  42. If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
  43.   MsgBox " datos incompletos ", vbCritical
  44.   Exit Sub
  45. End If
  46.  
  47. Call Reemplazar_Texto(Text1, Text2, Text3)
  48.  
  49. End Sub
  50.  

Bien la idea es la siguiente:
El
Text1 = "" <-- Es la ruta que esta al archivo
Text2 = "" <-- Busca
Text3 = "" <-- Reemplaza
CommandButton1 <-- Guarda los cambios

Código
  1. Private Sub Command1_Click()
  2. If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
  3.   MsgBox " datos incompletos ", vbCritical
  4.   Exit Sub
  5. End If
  6.  
  7. Call Reemplazar_Texto(Text1, Text2, Text3)
  8.  
  9. End Sub

Bue yo quiero que el Text1 Tenga 2 Rutas Que reemplaze en 2 Lugares por ej:
C:\Texto.txt y D:\Texto.txt


En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: Problemita path
« Respuesta #1 en: 25 Septiembre 2009, 19:31 pm »

Código
  1. split()
  2.  
  3.  
  separando por comas las rutas

c:\aaa.txt,f:\gvjjhgj.dat,d:\hfgjhg.exe

Código
  1. msgbox split(datos,",")(0)
  2. msgbox split(datos,",")(1)
  3. msgbox split(datos,",")(2)
  4.  
  5.  

o

Código
  1. dim rutas ()
  2. dim i as integer
  3. rutas=split(datos,",")
  4. for i=0 to ubound(rutas)-1
  5.    msgbox rutas(i)
  6. next i
  7.  
  8.  

P.D.: estas en un foro no en un chat aprende a escribir mejor.!¡

Bue este problemita me ta rompiendo vastantes las %"·&% :xD

Bue yo quiero que el Text1 Tenga 2 Rutas Que reemplaze en 2 Lugares por ej:
C:\Texto.txt y D:\Texto.txt


Dulces Lunas.


« Última modificación: 25 Septiembre 2009, 19:34 pm por BlackZeroX » En línea

The Dark Shadow is my passion.
Wii900

Desconectado Desconectado

Mensajes: 20


Ver Perfil
Re: Problemita path
« Respuesta #2 en: 26 Septiembre 2009, 01:19 am »

Bue men disculpa xD!!  ;D
No me retes jeje..

no entendi muy bien sobre las rutas me re perdi xDD!!

bue lo que ise fue crear otro textbox y un commandbutton el codigo me quedo asi


Código
  1. Private Sub Reemplazar_Texto(ByVal El_Archivo As String, _
  2.                            ByVal La_cadena As String, _
  3.                            ByVal Nueva_Cadena As String)
  4.  
  5. On Error GoTo errSub
  6. Dim F As Integer
  7. Dim Contenido As String
  8.  
  9.  
  10.    F = FreeFile
  11.  
  12.    Open El_Archivo For Input As F
  13.  
  14.    Contenido = Input$(LOF(F), #F)
  15.  
  16.    Close #F
  17.  
  18.    Contenido = Replace(Contenido, La_cadena, Nueva_Cadena)
  19.  
  20.  
  21.    F = FreeFile
  22.  
  23.    Open El_Archivo For Output As F
  24.  
  25.    Print #F, Contenido
  26.  
  27.  
  28.    Close #F
  29.  
  30.    MsgBox " Listo!!! ", vbInformation
  31. Exit Sub
  32.  
  33. 'Error
  34.  
  35. errSub:
  36. MsgBox Err.Description, vbCritical
  37. Close
  38. End Sub
  39.  
  40.  
  41. Private Sub Command1_Click()
  42. If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
  43.   MsgBox " datos incompletos ", vbCritical
  44.   Exit Sub
  45. End If
  46.  
  47. Call Reemplazar_Texto(Text1, Text2, Text3)
  48.  
  49. End Sub
  50. Private Sub Command2_Click()
  51. If (Text4 = "" Or Text5 = "" Or Text6 = "") Then
  52.   MsgBox " datos incompletos ", vbCritical
  53.   Exit Sub
  54. End If
  55.  
  56. Call Reemplazar_Texto(Text4, Text5, Text6)
  57. End Sub
Pero igual men gracias por responder   :D
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

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