Test Foro de elhacker.net SMF 2.1

Programación => Programación General => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: rapbyone en 18 Octubre 2013, 21:19 PM

Título: Mostrar texto en textbox desde archivo en servidor
Publicado por: rapbyone en 18 Octubre 2013, 21:19 PM
Mi consulta es la siguiente, tengo un código que me muestra en un textbox el contenido de un archivo.txt que esta en mi pc, mi pregunta es.

Como podría hacer lo mismo con un archivo de texto que esta en un servidor ?

El codigo es este:

Private Sub Form_load()
    Dim linea As String
    Dim c As String
   
' Muestra en textbox el contenido de archivo local version.txt

    Open "c:/version.txt" For Input As #1
    linea = ""
    Me.Text4.Text = ""
    While Not EOF(1)
        c = Input(1, #1)
        If c = "," Then
            Me.Text4.Text = Me.Text4.Text + linea + vbNewLine
            linea = ""
        Else
            linea = linea + c
        End If
    Wend
    If linea <> "" Then Me.Text4.Text = Me.Text4.Text + linea
    Close #1
   
  ' Muestra en textbox el contenido de  archivo version.txt desde servidor
   
    Open "http://miweb/updatepatch/version.txt" For Input As #1
    linea = ""
    Me.Text3.Text = ""
    While Not EOF(1)
        c = Input(1, #1)
        If c = "," Then
            Me.Text3.Text = Me.Text3.Text + linea + vbNewLine
            linea = ""
        Else
            linea = linea + c
        End If
    Wend
    If linea <> "" Then Me.Text3.Text = Me.Text3.Text + linea
    Close #1   

End Sub


Así se ve en mi programa:

(http://i55.servimg.com/u/f55/14/27/29/04/se_ve10.png)

Muchas, pero muchas gracias por la paciencia :D

Enviado desde mi GT-I9300 usando Tapatalk
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: Danyfirex en 19 Octubre 2013, 03:56 AM
Podrías hacer algo como esto

Código (vb) [Seleccionar]
Private Sub Form_Load()
Dim Msxml2 As Object
Set Msxml2 = CreateObject("Msxml2.XMLHTTP.3.0")
Msxml2.open "GET", "http://www.autoitscript.com/autoit3/docs/autoit_changelog_complete.txt", False
Msxml2.send
Text1.Text = Msxml2.responseText
End Sub


Saludos
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: rapbyone en 19 Octubre 2013, 16:33 PM
Cita de: Danyfirex en 19 Octubre 2013, 03:56 AM
Podrías hacer algo como esto

Código (vb) [Seleccionar]
Private Sub Form_Load()
Dim Msxml2 As Object
Set Msxml2 = CreateObject("Msxml2.XMLHTTP.3.0")
Msxml2.open "GET", "http://www.autoitscript.com/autoit3/docs/autoit_changelog_complete.txt", False
Msxml2.send
Text1.Text = Msxml2.responseText
End Sub


Saludos

Me funciono perfecto, el problema es que al cambiar el contenido del archivo en el servidor, no cambia en el textbox, sigue mostrando el anterior :S

Es como si descargara el archivo y después tomara los datos de ahí y no del servidor.

Muchas gracias :D ;-)
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: Danyfirex en 19 Octubre 2013, 18:44 PM
Debería funciona al llamar la función otra vez.
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: rapbyone en 20 Octubre 2013, 00:18 AM
Tienes toda la razon  ;-) :xD

muchas gracias tema resuelto :D
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: juandiegov en 23 Octubre 2013, 17:47 PM
Cita de: Danyfirex en 19 Octubre 2013, 03:56 AM
Podrías hacer algo como esto

Código (vb) [Seleccionar]
Private Sub Form_Load()
Dim Msxml2 As Object
Set Msxml2 = CreateObject("Msxml2.XMLHTTP.3.0")
Msxml2.open "GET", "http://www.autoitscript.com/autoit3/docs/autoit_changelog_complete.txt", False
Msxml2.send
Text1.Text = Msxml2.responseText
End Sub


Saludos

No me sirve :'(

asi lo tengo

Código (vbnet) [Seleccionar]
Private Sub Form_Load()
        Dim Msxml2 As Object
        Msxml2 = CreateObject("Msxml2.XMLHTTP.3.0")
        Msxml2.open("GET", "http://localhost/versionf.txt", False)
        Msxml2.send()
        Text1.Text = Msxml2.responseText


Tambien tengo el textbox
llamado text1
(http://masterlolohosting.tk/images/txtbox.png)
(http://masterlolohosting.tk/images/form1.png)

q tengo mal?

uso vb 2008

Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: Danyfirex en 23 Octubre 2013, 18:12 PM
Que error te da?

tal vez así:

Código (vbnet) [Seleccionar]


Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://localhost/versionf.txt")
Text1.Text=result



Saludos
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: juandiegov en 23 Octubre 2013, 18:29 PM
Cita de: Danyfirex en 23 Octubre 2013, 18:12 PM
Que error te da?

tal vez así:

Código (vbnet) [Seleccionar]


Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://localhost/versionf.txt")
Text1.Text=result



Saludos
gracias por responder tan rapido
no no me da error
pero no se muestra nada en el textbox
(http://masterlolohosting.tk/images/nada.png)
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: Danyfirex en 23 Octubre 2013, 21:04 PM
Coloca el textbox en multilinea.

Saludos
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: rapbyone en 24 Octubre 2013, 00:58 AM
Yo tampoco pude, asi que envés de textbox use un control webbrowser, si te interesa, te doy el código amigo
Título: Re: Mostrar texto en textbox desde archivo en servidor
Publicado por: Danyfirex en 24 Octubre 2013, 17:36 PM
Cita de: rapbyone en 24 Octubre 2013, 00:58 AM
Yo tampoco pude, asi que envés de textbox use un control webbrowser, si te interesa, te doy el código amigo

A mi me funciona de las dos formas que te coloqué.


No gracias no necesito el código.