Rediculous error makes no sense! Please help! 
Author Message
 Rediculous error makes no sense! Please help!

I have this command button, this is the code:

Private Sub Command1_Click()
    Dim intFile As Integer
        intFile = FreeFile()
    Dim strLine As String
    Dim strNew As String
    Dim strfile As String
    Dim intCount As Integer

    For intCount = 97 To 122
        Open "c:\temp11\" & Chr(intCount) & ".cfg" For Input As
intFile ' open files a.cfg - z.cfg
        Do Until EOF(intFile)
        Line Input #intFile, strLine
        strNew = "speak """ & strLine & """"
        strfile = strfile & vbCrLf & strNew
        Close intFile
        Open "c:\temp11\" & Chr(intCount) & Chr(intCount) & ".cfg" For
Output As intFile
        Print #intFile, strfile
        Close intFile
    Next intCount
End Sub

I keep getting compile error: Next without For

What the heck? There's clearly
For intCount = 97 to 122
right after the variable declarations...
I don't get it.
What could be causing this please?

Clear, dark skies to all.
-Atreju-
40.727966N
73.819530W



Sun, 02 Nov 2003 04:36:30 GMT  
 Rediculous error makes no sense! Please help!
Never mind... I found the problem. Loop statement was missing, so it
assumed the "Next" statement was nested.

D'OH!

On Tue, 15 May 2001 16:36:30 -0400, the following pearls of wisdom

Quote:
>I have this command button, this is the code:

>Private Sub Command1_Click()
>    Dim intFile As Integer
>        intFile = FreeFile()
>    Dim strLine As String
>    Dim strNew As String
>    Dim strfile As String
>    Dim intCount As Integer

>    For intCount = 97 To 122
>        Open "c:\temp11\" & Chr(intCount) & ".cfg" For Input As
>intFile ' open files a.cfg - z.cfg
>        Do Until EOF(intFile)
>        Line Input #intFile, strLine
>        strNew = "speak """ & strLine & """"
>        strfile = strfile & vbCrLf & strNew
>        Close intFile
>        Open "c:\temp11\" & Chr(intCount) & Chr(intCount) & ".cfg" For
>Output As intFile
>        Print #intFile, strfile
>        Close intFile
>    Next intCount
>End Sub

>I keep getting compile error: Next without For

>What the heck? There's clearly
>For intCount = 97 to 122
>right after the variable declarations...
>I don't get it.
>What could be causing this please?

>Clear, dark skies to all.
>-Atreju-
>40.727966N
>73.819530W

Clear, dark skies to all.
-Atreju-
40.727966N
73.819530W


Sun, 02 Nov 2003 04:40:46 GMT  
 Rediculous error makes no sense! Please help!
Here's a lesson in careful nested indenting. Let me assist:


Quote:
> I have this command button, this is the code:

> Private Sub Command1_Click()
>     Dim intFile As Integer
>         intFile = FreeFile()
>     Dim strLine As String
>     Dim strNew As String
>     Dim strfile As String
>     Dim intCount As Integer

     For intCount = 97 To 122
         Open "c:\temp11\" & Chr(intCount) & ".cfg" For Input As intFile '
open files a.cfg - z.cfg
         Do Until EOF(intFile)
           Line Input #intFile, strLine
           strNew = "speak """ & strLine & """"
           strfile = strfile & vbCrLf & strNew
           Close intFile
           Open "c:\temp11\" & Chr(intCount) & Chr(intCount) & ".cfg" For
Output As intFile
           Print #intFile, strfile
           Close intFile

'And here we see no Loop for the Do.

     Next intCount
 End Sub

Quote:

> I keep getting compile error: Next without For

> What the heck? There's clearly
> For intCount = 97 to 122
> right after the variable declarations...
> I don't get it.
> What could be causing this please?

VB sometimes gives the wrong error message.
It should be telling you Do without Loop, but instead,
it finds a Next that doesn't connect to a For inside
the Do-Loop structure.

Real pain in the ass, isn't it? Been there a hundred
times myself. I've finally gotten myself trained
to

A) Nest indents, and

B) Automatically type in the closing command for
anything that requires it, without even thinking.

If I type For, I automatically hit enter a couple
of times, and type Next. Then, backtrack and
work on what's in between.

Terry Austin



Sun, 02 Nov 2003 05:06:41 GMT  
 Rediculous error makes no sense! Please help!

<cut>

Quote:
> If I type For, I automatically hit enter a couple
> of times, and type Next. Then, backtrack and
> work on what's in between.

LOL.  I finally made an add-in to handle adding Next/End Select/End If/etc
easily.  It made life MUCH easier.  This is one thing that's really nice in
the new dotnet editor since all these ending tags are added automatically
when you type the opening statement.  Of course it means that large parts of
my add-in are now superfluous...


Sun, 02 Nov 2003 05:59:01 GMT  
 Rediculous error makes no sense! Please help!


Quote:


> <cut>
> > If I type For, I automatically hit enter a couple
> > of times, and type Next. Then, backtrack and
> > work on what's in between.

> LOL.  I finally made an add-in to handle adding Next/End Select/End If/etc
> easily.

Sounds useful.

Quote:
>It made life MUCH easier.

I don't doubt it.

Quote:
> This is one thing that's really nice in
> the new dotnet editor since all these ending tags are added automatically
> when you type the opening statement.  Of course it means that large parts
of
> my add-in are now superfluous...

So there's actually a change or two that are not for the worse?
I'm amazed. ;)

Terry Austin



Sun, 02 Nov 2003 06:22:09 GMT  
 Rediculous error makes no sense! Please help!
Wow!  I didn't even know you could do that.  I have wanted to for a long
time though.  Is there any way that you could e-mail that Add-in to me?  I
can imagine it being VERY useful (no more forgetting AND less typing, what
else could one ask for?).

Thanks in advance,
Christopher

Quote:
>LOL.  I finally made an add-in to handle adding Next/End Select/End If/etc
>easily.  It made life MUCH easier.  This is one thing that's really nice in
>the new dotnet editor since all these ending tags are added automatically
>when you type the opening statement.  Of course it means that large parts
of
>my add-in are now superfluous...



Sun, 02 Nov 2003 11:25:48 GMT  
 Rediculous error makes no sense! Please help!


Quote:
> Wow!  I didn't even know you could do that.  I have wanted to for a long
> time though.  Is there any way that you could e-mail that Add-in to me?  I
> can imagine it being VERY useful (no more forgetting AND less typing, what
> else could one ask for?).

I did a *major* hack since the add-in model does not provide feedback when
code is added.  My addin uses a timer and just checks the currently selected
line periodically.  If the line ends with the open/close square brackets it
removes them and inserts the closing syntax indented to the same level.  I
type, for example:
     if x=5[]
and after a very brief pause the code reads
     if x=5 then
        (cursor is sitting here indented extra spaces)
     end if

(The exact character sequence and the number of extra spaces to indent is
configurable)  It also has some other features for closing all project
windows when you close a project, renaming event procedures when you rename
controls on a form, inserting code snippets, adding Option statements and
setting default properties on controls when you add them to a form (e.g.
when I add a listbox it comes in Sorted=True and MultiSelect=2 since that's
much more common for me to need)

I'll give some thought to making it available generally.  I haven't so far
simply because it's been a work in progress for a while and really needs to
be designed from the ground up instead of being the hack of pieces grafted
onto pieces that it is now.  It's also not something I can support since I
just don't have the time for that.



Sun, 02 Nov 2003 22:51:42 GMT  
 Rediculous error makes no sense! Please help!
Well understood.  I have a few applications that I'd hate to see unleashed
on the world no matter how useful they could be (when they're *done*).
Well, if you ever get around "fixing" to it, let me know, I help you beta
test :-)




Quote:
> Wow!  I didn't even know you could do that.  I have wanted to for a long
> time though.  Is there any way that you could e-mail that Add-in to me?  I
> can imagine it being VERY useful (no more forgetting AND less typing, what
> else could one ask for?).

I did a *major* hack since the add-in model does not provide feedback when
code is added.  My addin uses a timer and just checks the currently selected
line periodically.  If the line ends with the open/close square brackets it
removes them and inserts the closing syntax indented to the same level.  I
type, for example:
     if x=5[]
and after a very brief pause the code reads
     if x=5 then
        (cursor is sitting here indented extra spaces)
     end if

(The exact character sequence and the number of extra spaces to indent is
configurable)  It also has some other features for closing all project
windows when you close a project, renaming event procedures when you rename
controls on a form, inserting code snippets, adding Option statements and
setting default properties on controls when you add them to a form (e.g.
when I add a listbox it comes in Sorted=True and MultiSelect=2 since that's
much more common for me to need)

I'll give some thought to making it available generally.  I haven't so far
simply because it's been a work in progress for a while and really needs to
be designed from the ground up instead of being the hack of pieces grafted
onto pieces that it is now.  It's also not something I can support since I
just don't have the time for that.



Mon, 03 Nov 2003 06:20:26 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. VBX makes sense, OCX makes sense - What is OCA?

3. making sense of access form design

4. Makes no sense! (I think)

5. Making sense out of binary data

6. Does it makes any sense? (Working with MSComm)

7. Making sense of AVI_COMPRESS_OPTIONS

8. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

9. overflow error - does it make sense to you ?

10. Database grows by rediculous size when using recordset and Edit command

11. Access makes me desperate - Please help me!

12. VB friends ... please help with making a control

 

 
Powered by phpBB® Forum Software