Bue este problemita me ta rompiendo vastantes las %"·&% :xD
este es el codigo
Private Sub Reemplazar_Texto(ByVal El_Archivo As String, _
ByVal La_cadena As String, _
ByVal Nueva_Cadena As String)
On Error GoTo errSub
Dim F As Integer
Dim Contenido As String
F = FreeFile
Open El_Archivo For Input As F
Contenido = Input$(LOF(F), #F)
Close #F
Contenido = Replace(Contenido, La_cadena, Nueva_Cadena)
F = FreeFile
Open El_Archivo For Output As F
Print #F, Contenido
Close #F
MsgBox " Listo!!! ", vbInformation
Exit Sub
'Error
errSub:
MsgBox Err.Description, vbCritical
Close
End Sub
Private Sub Command1_Click()
If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
MsgBox " datos incompletos ", vbCritical
Exit Sub
End If
Call Reemplazar_Texto(Text1, Text2, Text3)
End Sub
Bien la idea es la siguiente:
El
Text1 = "" <-- Es la ruta que esta al archivo
Text2 = "" <-- Busca
Text3 = "" <-- Reemplaza
CommandButton1 <-- Guarda los cambios
Private Sub Command1_Click()
If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
MsgBox " datos incompletos ", vbCritical
Exit Sub
End If
Call Reemplazar_Texto(Text1, Text2, Text3)
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
split()
separando por comas las rutas
c:\aaa.txt,f:\gvjjhgj.dat,d:\hfgjhg.exe
msgbox split(datos,",")(0)
msgbox split(datos,",")(1)
msgbox split(datos,",")(2)
o
dim rutas ()
dim i as integer
rutas=split(datos,",")
for i=0 to ubound(rutas)-1
msgbox rutas(i)
next i
P.D.: estas en un foro no en un chat aprende a escribir mejor.!¡
Cita de: Wii900 en 25 Septiembre 2009, 18:28 PM
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.
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
Private Sub Reemplazar_Texto(ByVal El_Archivo As String, _
ByVal La_cadena As String, _
ByVal Nueva_Cadena As String)
On Error GoTo errSub
Dim F As Integer
Dim Contenido As String
F = FreeFile
Open El_Archivo For Input As F
Contenido = Input$(LOF(F), #F)
Close #F
Contenido = Replace(Contenido, La_cadena, Nueva_Cadena)
F = FreeFile
Open El_Archivo For Output As F
Print #F, Contenido
Close #F
MsgBox " Listo!!! ", vbInformation
Exit Sub
'Error
errSub:
MsgBox Err.Description, vbCritical
Close
End Sub
Private Sub Command1_Click()
If (Text1 = "" Or Text2 = "" Or Text3 = "") Then
MsgBox " datos incompletos ", vbCritical
Exit Sub
End If
Call Reemplazar_Texto(Text1, Text2, Text3)
End Sub
Private Sub Command2_Click()
If (Text4 = "" Or Text5 = "" Or Text6 = "") Then
MsgBox " datos incompletos ", vbCritical
Exit Sub
End If
Call Reemplazar_Texto(Text4, Text5, Text6)
End Sub
Pero igual men gracias por responder :D