Reading a text file and piping it into a text box 
Author Message
 Reading a text file and piping it into a text box

Greetings. I can use the following code segment to read the contents
of a text file (called writefile.txt) and display it on the screen.

<%
    Set fs = CreateObject("Scripting.FileSystemObject")
    filename=server.mappath("writefile.txt")
        Set readfile=fs.OpenTextFile(filename,1,False)
    Do until readfile.AtEndOfStream
        Text=readfile.readline
        If Text="" then
            response.write "<p>"
        Else
            response.write Text
        End If
    Loop
    readfile.close
    set readfile=nothing
%>

I am not sure how to modify this code to have it display in a text box
on a page. I would like to have an small text box called "News" where
I can put a message of the day, etc. Any help would be greatly
appreciated. Thanks.

Sam



Mon, 01 Nov 2004 11:48:29 GMT  
 Reading a text file and piping it into a text box
Im not sure if textbox can support multiline, but you can try the following
asp code.

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>

<%
    Set fs = CreateObject( "Scripting.FileSystemObject")
    Set readfile = fs.OpenTextFile( "d:\labs\marx.txt", 1)

    response.write( "<SCRIPT LANGUAGE=VBScript>" & chr(13))
    Do until readfile.AtEndOfStream
        Text = readfile.readline
        response.write( "sText = sText & """ & Text & """" & chr(13))
    Loop

    readfile.close
    set readfile=nothing
    response.write( "</SCRIPT>")
%>

<SCRIPT LANGUAGE=vbscript>
<!--
sub window_onload()
    text1.value = sText
end sub
//-->
</SCRIPT>

</HEAD>
<BODY LANGUAGE=vbscript onload="call window_onload">
<INPUT id=text1 name=text1>
</BODY>
</HTML>


Quote:
> Greetings. I can use the following code segment to read the contents
> of a text file (called writefile.txt) and display it on the screen.

> <%
>     Set fs = CreateObject("Scripting.FileSystemObject")
>     filename=server.mappath("writefile.txt")
> Set readfile=fs.OpenTextFile(filename,1,False)
>     Do until readfile.AtEndOfStream
>         Text=readfile.readline
>         If Text="" then
>             response.write "<p>"
>         Else
>             response.write Text
>         End If
>     Loop
>     readfile.close
>     set readfile=nothing
> %>

> I am not sure how to modify this code to have it display in a text box
> on a page. I would like to have an small text box called "News" where
> I can put a message of the day, etc. Any help would be greatly
> appreciated. Thanks.

> Sam



Mon, 01 Nov 2004 14:11:28 GMT  
 Reading a text file and piping it into a text box
sam,

<textarea rows="10" columns="5" name="text1" id="text1"/> is a multi-line
text box

or you could use <iFrame width="100" height="100" src="d:\labs\marx.txt"/>
bypassing vbscript alltogether

-hman


Quote:
> Im not sure if textbox can support multiline, but you can try the
following
> asp code.

> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
> <TITLE></TITLE>

> <%
>     Set fs = CreateObject( "Scripting.FileSystemObject")
>     Set readfile = fs.OpenTextFile( "d:\labs\marx.txt", 1)

>     response.write( "<SCRIPT LANGUAGE=vbscript>" & chr(13))
>     Do until readfile.AtEndOfStream
>         Text = readfile.readline
>         response.write( "sText = sText & """ & Text & """" & chr(13))
>     Loop

>     readfile.close
>     set readfile=nothing
>     response.write( "</SCRIPT>")
> %>

> <SCRIPT LANGUAGE=vbscript>
> <!--
> sub window_onload()
>     text1.value = sText
> end sub
> //-->
> </SCRIPT>

> </HEAD>
> <BODY LANGUAGE=vbscript onload="call window_onload">
> <INPUT id=text1 name=text1>
> </BODY>
> </HTML>



> > Greetings. I can use the following code segment to read the contents
> > of a text file (called writefile.txt) and display it on the screen.

> > <%
> >     Set fs = CreateObject("Scripting.FileSystemObject")
> >     filename=server.mappath("writefile.txt")
> > Set readfile=fs.OpenTextFile(filename,1,False)
> >     Do until readfile.AtEndOfStream
> >         Text=readfile.readline
> >         If Text="" then
> >             response.write "<p>"
> >         Else
> >             response.write Text
> >         End If
> >     Loop
> >     readfile.close
> >     set readfile=nothing
> > %>

> > I am not sure how to modify this code to have it display in a text box
> > on a page. I would like to have an small text box called "News" where
> > I can put a message of the day, etc. Any help would be greatly
> > appreciated. Thanks.

> > Sam



Mon, 01 Nov 2004 22:21:55 GMT  
 Reading a text file and piping it into a text box
Thank you. The <iFrame> worked like a charm.

Sam

Quote:
>-----Original Message-----
>sam,

><textarea rows="10" columns="5" name="text1" id="text1"/>
is a multi-line
>text box

>or you could use <iFrame width="100" height="100"

src="d:\labs\marx.txt"/>
Quote:
>bypassing vbscript alltogether

>-hman



>> Im not sure if textbox can support multiline, but you
can try the
>following
>> asp code.

>> <HTML>
>> <HEAD>
>> <META NAME="GENERATOR" Content="Microsoft Visual Studio
6.0">
>> <TITLE></TITLE>

>> <%
>>     Set fs = CreateObject( "Scripting.FileSystemObject")
>>     Set readfile = fs.OpenTextFile( "d:\labs\marx.txt",
1)

>>     response.write( "<SCRIPT LANGUAGE=vbscript>" & chr
(13))
>>     Do until readfile.AtEndOfStream
>>         Text = readfile.readline
>>         response.write( "sText = sText & """ & Text
& """" & chr(13))
>>     Loop

>>     readfile.close
>>     set readfile=nothing
>>     response.write( "</SCRIPT>")
>> %>

>> <SCRIPT LANGUAGE=vbscript>
>> <!--
>> sub window_onload()
>>     text1.value = sText
>> end sub
>> //-->
>> </SCRIPT>

>> </HEAD>
>> <BODY LANGUAGE=vbscript onload="call window_onload">
>> <INPUT id=text1 name=text1>
>> </BODY>
>> </HTML>



>> > Greetings. I can use the following code segment to
read the contents
>> > of a text file (called writefile.txt) and display it
on the screen.

>> > <%
>> >     Set fs = CreateObject

("Scripting.FileSystemObject")
Quote:
>> >     filename=server.mappath("writefile.txt")
>> > Set readfile=fs.OpenTextFile(filename,1,False)
>> >     Do until readfile.AtEndOfStream
>> >         Text=readfile.readline
>> >         If Text="" then
>> >             response.write "<p>"
>> >         Else
>> >             response.write Text
>> >         End If
>> >     Loop
>> >     readfile.close
>> >     set readfile=nothing
>> > %>

>> > I am not sure how to modify this code to have it

display in a text box

- Show quoted text -

Quote:
>> > on a page. I would like to have an small text box
called "News" where
>> > I can put a message of the day, etc. Any help would
be greatly
>> > appreciated. Thanks.

>> > Sam

>.



Mon, 01 Nov 2004 23:59:35 GMT  
 Reading a text file and piping it into a text box
You do not need to read each line in this case:

<%
Dim fs, filename, readfile, NewsBody

Set fs = CreateObject("Scripting.FileSystemObject")
filename = server.mappath("writefile.txt")
Set readfile=fs.OpenTextFile(filename, 1, False)
NewsBody = readfile.ReadAll
readfile.Close
Response.Write "<textarea rows='10' name='News' cols='40'>" & _
                            NewsBody & "</textarea>"
%>

Regards,
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:
> Greetings. I can use the following code segment to read the contents
> of a text file (called writefile.txt) and display it on the screen.

> <%
>     Set fs = CreateObject("Scripting.FileSystemObject")
>     filename=server.mappath("writefile.txt")
> Set readfile=fs.OpenTextFile(filename,1,False)
>     Do until readfile.AtEndOfStream
>         Text=readfile.readline
>         If Text="" then
>             response.write "<p>"
>         Else
>             response.write Text
>         End If
>     Loop
>     readfile.close
>     set readfile=nothing
> %>

> I am not sure how to modify this code to have it display in a text box
> on a page. I would like to have an small text box called "News" where
> I can put a message of the day, etc. Any help would be greatly
> appreciated. Thanks.

> Sam



Tue, 02 Nov 2004 00:04:15 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Text box text on new page text box

2. reading a text file to display in text box

3. Reading file name from text box and/or File List Box

4. Reading from a text file and writing toa text file from Vis Bas 6.0

5. how to read a txt file to text box

6. creating a text box errors message for empty text box

7. how to read a txt file to text box

8. passing variables from a text box to a document.write text box

9. Reading text from a text file into a variable

10. Reading text from another program's Rich Text Box

11. How to read partial text in a line of a text file

12. VB Text Database driver / reading text files

 

 
Powered by phpBB® Forum Software