473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Expected end of statement problem

Having a nightmare problem with this and would appreciate any and all help.

The situation is I want to move from a webform and format the user
inputted text into some html I am storing in a template file on my server.

I have to admit to being entirley new to ASP and so much of what follows
is probably absolute nonsense.

<%
Option Explicit
Imports Microsoft.VisualBasic
Imports System
Imports System.IO

Class Test
Public Sub Main()
Try
' Create an instance of StreamReader to read from a ' file.
Dim sr, sw
Dim filename, openText, apologiesText, treasurerText,
secretaryText, commentsText

'creates the filename
theMonth = Request.Form("month")
theYear = Request.Form("year")
filename = ""&theMonth&""&theYear&".txt"

sr = New StreamReader("minutesTemplate.txt")
sw = New StreamWriter(filename)

Dim line As String

' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()

'this case statement is going to need some 'refining.
Select Case line
Case "---Opening Comments---"
openText=Request.Form("open")
sw.write(openText)
Case "---Apologies---"
apologiesText=Request.Form("apologies")
sw.write(apologiesText)
Case "---Treasurer Report---"
treasurerText=Request.Form("treasurer")
sw.write(treasurerText)
Case "---Secretary Report---"
secretaryText=Request.Form("secretary")
sw.write(secretaryText)
Case "---Additional Comments---"
commentsText=Request.Form("comments")
sw.write(commentsText)
Case else
break
End Select
Loop Until line Is Nothing
sr.Close()
sw.Close()
Catch E As Exception
' Let the user know what went wrong.
'Console.WriteLine("The file could not be read:")
'Console.WriteLine(E.Message)
End Try
End Sub
End Class
%>

The error message I'm getting at the moment is

Microsoft VBScript compilation error '800a0401'

Expected end of statement

sr = New StreamReader("minutesTemplate.txt")
---------------------^

As before, any help would be great!

Thanks

Graham

Jul 19 '05 #1
7 16344
I'm not clear if this is a .NET question ("webforms", "StreamReader") or
not. If you are using .NET, then you need to post this to a dotnet newsgroup
as this group is focussed on classic ASP. I suggest
microsoft.public.dotnet.framework.aspnet
HTH,
Bob Barrows
Jul 19 '05 #2
http://www.aspfaq.com/5002

Ray at work

"Graham James Campbell CS2000" <gj*************@cis.strath.ac.uk> wrote in
message news:3f********@nntphost.cis.strath.ac.uk...
Having a nightmare problem with this and would appreciate any and all help.
<%
Imports Microsoft.VisualBasic
Imports System
Imports System.IO

Jul 19 '05 #3
one of the .aspnet groups wuld be more appropriate. Off the top of my
head, though, as a C# (not VB) user, don't you have to use the SET
keyword here?

________________________________________
Atrax. MVP, IIS
http://rtfm.atrax.co.uk/

newsflash : Atrax.Richedit 1.0 now released.
http://rtfm.atrax.co.uk/infinitemonk...trax.RichEdit/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
one of the .aspnet groups wuld be more appropriate. Off the top of my
head, though, as a C# (not VB) user, don't you have to use the SET
keyword here?

hang on, I take that back. the docs say :

Dim sr As StreamReader = New StreamReader(path)


________________________________________
Atrax. MVP, IIS
http://rtfm.atrax.co.uk/

newsflash : Atrax.Richedit 1.0 now released.
http://rtfm.atrax.co.uk/infinitemonk...trax.RichEdit/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #5
First, you need some spaces around your ampersands:

filename = ""&theMonth&""&theYear&".txt"

should be:

filename = "" & theMonth & "" & theYear & ".txt"

Second, are you using ASP.NET or ASP? This:
sr = New StreamReader("minutesTemplate.txt")
appears to be VB.NET. If so, you should post to
microsoft.public.dotnet.aspnet group. If ASP, you cannot use Streamreaders
(1) and the syntax is wrong if you could:

Set sr = Server.CreateObject("StreamReader")

This is correct syntax, but there is no StreamReader in traditional ASP.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Graham James Campbell CS2000" <gj*************@cis.strath.ac.uk> wrote in
message news:3f********@nntphost.cis.strath.ac.uk... Having a nightmare problem with this and would appreciate any and all help.
The situation is I want to move from a webform and format the user
inputted text into some html I am storing in a template file on my server.

I have to admit to being entirley new to ASP and so much of what follows
is probably absolute nonsense.

<%
Option Explicit
Imports Microsoft.VisualBasic
Imports System
Imports System.IO

Class Test
Public Sub Main()
Try
' Create an instance of StreamReader to read from a ' file.
Dim sr, sw
Dim filename, openText, apologiesText, treasurerText,
secretaryText, commentsText

'creates the filename
theMonth = Request.Form("month")
theYear = Request.Form("year")
filename = ""&theMonth&""&theYear&".txt"

sr = New StreamReader("minutesTemplate.txt")
sw = New StreamWriter(filename)

Dim line As String

' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()

'this case statement is going to need some 'refining.
Select Case line
Case "---Opening Comments---"
openText=Request.Form("open")
sw.write(openText)
Case "---Apologies---"
apologiesText=Request.Form("apologies")
sw.write(apologiesText)
Case "---Treasurer Report---"
treasurerText=Request.Form("treasurer")
sw.write(treasurerText)
Case "---Secretary Report---"
secretaryText=Request.Form("secretary")
sw.write(secretaryText)
Case "---Additional Comments---"
commentsText=Request.Form("comments")
sw.write(commentsText)
Case else
break
End Select
Loop Until line Is Nothing
sr.Close()
sw.Close()
Catch E As Exception
' Let the user know what went wrong.
'Console.WriteLine("The file could not be read:")
'Console.WriteLine(E.Message)
End Try
End Sub
End Class
%>

The error message I'm getting at the moment is

Microsoft VBScript compilation error '800a0401'

Expected end of statement

sr = New StreamReader("minutesTemplate.txt")
---------------------^

As before, any help would be great!

Thanks

Graham



Jul 19 '05 #6
It depends on whether it was dimensioned or not. Both of these are
equivalent:

Dim sr As StreamReader = New StreamReader(path)

Dim sr As StreamReader
sr = New StreamReader(path)

In C# (in case he wants to go to a real language *duck* only kidding, I code
both):

StreamReader sr = new StreamReader(path);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Atrax" <at***@dontspamatrax.co.uk> wrote in message
news:OT**************@tk2msftngp13.phx.gbl...
one of the .aspnet groups wuld be more appropriate. Off the top of my
head, though, as a C# (not VB) user, don't you have to use the SET
keyword here?

hang on, I take that back. the docs say :

Dim sr As StreamReader = New StreamReader(path)


________________________________________
Atrax. MVP, IIS
http://rtfm.atrax.co.uk/

newsflash : Atrax.Richedit 1.0 now released.
http://rtfm.atrax.co.uk/infinitemonk...trax.RichEdit/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #7
Dang. Thought I might be in the wrong NG. Thanks for putting me right! :)

Graham

Graham James Campbell CS2000 wrote:
[snip]
Thanks

Graham

--
"This is my country, the land that begat me. These windy spaces, are
surely my own."
- Alexander Gray

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation...
5
by: Agoston Bejo | last post by:
I am generating WML pages from ASP. I have header.inc that looks like this: ---------------------------------------------- <%@Language=VBScript%><% Option Explicit Response.Buffer = True...
13
by: Squid Seven | last post by:
This is just bizarre. for the following snippet of code: #include <string> using std::string; I get the error message:
5
by: andy.herrera | last post by:
I'm getting this Error Message. Expected ';' Please Select One: <form name="form1"> <<------------ Error is here. <select name="selectTrans" onChange="If (this.value == 'checkout')...
2
by: Edward S | last post by:
I would appreciate if someone could correct my SQL statement which is displaying a message Expected : End of Statement this statment is attached to a button on the form StrSQL = "PARAMETERS !!...
3
by: NeilH | last post by:
Hello All I was wondering if someone could offer a rather inexperienced person some advice. Im trying to get my asp page to look at an access data I created the following query in access...
35
by: Marchel | last post by:
For a long time I was a gib fan of Borland C++ Builder with VCL framework and never gave a second look in Microsoft products since I've seen MFC. Anyway, recently Borland decided out of the blue to...
39
by: eruanion | last post by:
Hi, I've been working on this for a while now and I can't seem to find out what is wrong with my code. I have 2 files one c3common.js which only contains javascript functions for my main html page...
3
by: Dax | last post by:
Hi, during the creation of an HTML page using asp variable I have this problem: Microsoft VBScript compilation (0x800A0401) Expected end of statement /asp/pages/connect1_1.asp, line 27, column 35...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.