Expected end of statement problem

Discussion in 'ASP General' started by Graham James Campbell CS2000, Oct 3, 2003.

  1. 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
    Graham James Campbell CS2000, Oct 3, 2003
    #1
    1. Advertising

  2. Graham James Campbell CS2000

    Bob Barrows Guest

    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
    Bob Barrows, Oct 3, 2003
    #2
    1. Advertising

  3. Graham James Campbell CS2000

    Ray at Guest

    http://www.aspfaq.com/5002

    Ray at work

    "Graham James Campbell CS2000" <> wrote in
    message news:3f7d6a83$...
    > Having a nightmare problem with this and would appreciate any and all

    help.
    >
    > <%
    > Imports Microsoft.VisualBasic
    > Imports System
    > Imports System.IO
    >
    Ray at, Oct 3, 2003
    #3
  4. Graham James Campbell CS2000

    Atrax Guest

    Atrax, Oct 3, 2003
    #4
  5. Graham James Campbell CS2000

    Atrax Guest

    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/infinitemonkeys/components/Atrax.RichEdit/

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Atrax, Oct 3, 2003
    #5
  6. 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" <> wrote in
    message news:3f7d6a83$...
    > 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
    >
    msnews.microsoft.com, Oct 3, 2003
    #6
  7. 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" <> wrote in message
    news:...
    > 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/infinitemonkeys/components/Atrax.RichEdit/
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    msnews.microsoft.com, Oct 3, 2003
    #7
  8. 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
    Graham Campbell, Oct 3, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JJY
    Replies:
    1
    Views:
    2,565
    Ken Cox [Microsoft MVP]
    Dec 23, 2003
  2. momo

    End of statement expected error

    momo, Mar 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    12,032
    Erik Funkenbusch
    Mar 20, 2006
  3. PaulT

    End of statement expected

    PaulT, Oct 2, 2008, in forum: .NET
    Replies:
    0
    Views:
    450
    PaulT
    Oct 2, 2008
  4. Phil Powell
    Replies:
    1
    Views:
    205
    Ray at
    Jul 10, 2003
  5. Dax
    Replies:
    3
    Views:
    137
Loading...

Share This Page