Expected end of statement problem

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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

    Graham James Campbell CS2000 Guest

  2. Similar Questions and Discussions

    1. Expected end of statement
      Hi all, This will be my 1st post on here! i am trying to view a list of files within a folder on my server drive using this bit of code. <%...
    2. The DREADED Expected end of statement
      Microsoft VBScript compilation error '800a0401' Can someone please look at my code and tell me what the deal is? I am stumped. Expected end of...
    3. Expected end of statement
      Try this instead provider=Microsoft.Jet.oledb.4.0;Data Source=c:\testapp\asp_test.mdb; User ID=('admin'); Password=("")
    4. Expected end of statement
      Can you post the EXACT error you're getting?
    5. 800A0401: Expected End of Statement
      I am trying to get this code going but always the following error message: Error Type: Microsoft VBScript compilation (0x800A0401) Expected end...
  3. #2

    Default Re: Expected end of statement problem

    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 Guest

  4. #3

    Default Re: Expected end of statement problem

    [url]http://www.aspfaq.com/5002[/url]

    Ray at work

    "Graham James Campbell CS2000" <gjcampbe+usenet@cis.strath.ac.uk> wrote in
    message news:3f7d6a83$1@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
    >

    Ray at Guest

  5. #4

    Default Re: Expected end of statement problem

    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
    [url]http://rtfm.atrax.co.uk/[/url]

    newsflash : Atrax.Richedit 1.0 now released.
    [url]http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/[/url]

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

  6. #5

    Default Re: Expected end of statement problem

    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
    [url]http://rtfm.atrax.co.uk/[/url]

    newsflash : Atrax.Richedit 1.0 now released.
    [url]http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/[/url]

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

  7. #6

    Default Re: Expected end of statement problem

    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" <gjcampbe+usenet@cis.strath.ac.uk> wrote in
    message news:3f7d6a83$1@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
    >



    msnews.microsoft.com Guest

  8. #7

    Default Re: Expected end of statement problem

    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" <atrax@dontspamatrax.co.uk> wrote in message
    news:OTeUuzbiDHA.3832@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
    > [url]http://rtfm.atrax.co.uk/[/url]
    >
    > newsflash : Atrax.Richedit 1.0 now released.
    > [url]http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/[/url]
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    msnews.microsoft.com Guest

  9. #8

    Default Re: Expected end of statement problem

    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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139