Necesito programa sencillo automatizado

Iniciado por K-19, 2 Noviembre 2009, 17:07 PM

0 Miembros y 2 Visitantes están viendo este tema.

K-19

Hola a todos, necesito algo que me lea un txt o que yo mismo inserte en un textbox una secuencia de texto tal que asi:

http://www.foto1.jpg http://www.lamejorwebdelmundomundial.com
http://www.foto2.jpg http://www.google.es
http://www.foto3.jpg http://www.mediavida.com


Y que al darle a un boton me lo convierta asi:

<a href="http://www.lamejorwebdelmundomundial.com" target="_blank"><img class="alignnone" src="http://www.foto1.jpg" alt="" width="120" height="90" /></a><a href="http://www.google.es" target="_blank"><img class="alignnone" src="http://www.foto2.jpg" alt="" width="120" height="90" /></a><a href="http://www.mediavida.com" target="_blank"><img class="alignnone" src="http://www.foto3.jpg" alt="" width="120" height="90" /></a>


La idea la tengo clara pero llevo años sin tocar el visualbasic... seria algo así como tener una plantilla del estilo:

<a href="$web" target="_blank"><img class="alignnone" src="$foto" alt="" width="120" height="90" /></a>

Y cuando lea el txt o el texto insertado en un textbox tome la primera url como variable $web y la segunda como $foto y que lo reemplaze y que añada otra plantilla para realizar lo mismo con la siguiente secuencia de urls.

Gracias de antemano

DarkMatrix

#1
En un formulario pon un  textbox con multiline en true y scrollbars en Both, y un command botton ambos con nombres por defecto. en el codigo:

Código (vb) [Seleccionar]


Private Sub Command1_Click()

   Dim Imagen As String
   Dim Url As String
   Dim PathArchivo As String

   PathArchivo = "C:\Archivo.txt"

   Open PathArchivo For Input As #1
   While Not EOF(1)
   Input #1, Imagen, Url
   Text1.Text = Text1.Text & "<a href=""" & Url & """ target=""_blank""><img class=""alignnone"" src=""" & Imagen & """ alt="" width=""120"" height=""90"" /></a>" & vbCrLf
   Wend
   Close #1

End Sub


el archivo de texto debe estar asi:



http://www.foto1.jpg, http://www.lamejorwebdelmundomundial.com
http://www.foto2.jpg, http://www.google.es
http://www.foto3.jpg, http://www.mediavida.com



La foto debe estar separada de la url con una coma y cuando pulses el command 1 el resultado apàrecera en el text 1. espero que te sirva Saludos XD!!!

Todo aquello que no se puede hacer, es lo que no intentamos hacer.
Projecto Ani-Dimension Digital Duel Masters (Juego de cartas masivo multijugador online hecho en Visual Basic 6.0)

Desing by DarkMatrix

K-19

se agredece tu aporte pero como se haria para no tener que separar el link de la imagen y de la web por una coma? (,)

me gustaria que fuese un simple espacio, he intentado hacer retokes pero no me sale.

Dessa



Private Sub Command1_Click()

Dim linea As String
Dim PathArchivo As String
PathArchivo = "C:\Archivo.txt"

Open PathArchivo For Input As #1
   While Not EOF(1)
     Line Input #1, linea
     Dim linea2() As String
     linea2() = Split(linea, " ")
     Text1.Text = Text1.Text & "<a href=""" & linea2(1) & """ target=""_blank""><img class=""alignnone"" src=""" & linea2(0) & """ alt="" width=""120"" height=""90"" /></a>" & vbCrLf
   Wend
Close #1

End Sub




Adrian Desanti

DarkMatrix

Exactamente como lo coloco el amigo Dessa Saludos xD!!

Todo aquello que no se puede hacer, es lo que no intentamos hacer.
Projecto Ani-Dimension Digital Duel Masters (Juego de cartas masivo multijugador online hecho en Visual Basic 6.0)

Desing by DarkMatrix

Dessa

agrega el siguiente if

     If linea <> "" Then Text1.Text = Text1.Text & "<a href=""" & linea2(1) & """ target=""_blank""><img class=""alignnone"" src=""" & linea2(0) & """ alt="" width=""120"" height=""90"" /></a>" & vbCrLf

S2
Adrian Desanti