|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
For Next Loop - Manual Might Be Wrong"Note: also that you can decalre the index variable in a For Loop using the optional AS datatype clause, as long as the index variable isnt already declared eslewhere. ( This is new to Visual Basic.net 2003 ) It then gives the example : For intLoopIndex As Integer = 0 To 1 'This next line i have dummy'd down cause they use it to print an array element so like Foo( intLoopIndex ) Console.WriteLine("Hello") Next intLoopIndex It does not mention having option strict on and option explicit on. I have them both on. My simple solution is to just dim it before, cause it complaines that intLoopIndex is not declared. Im assuming its either because of the Option Strict and Option Explicit and not a typo ( somehow ) in the book. Miro this works fine for me...with Optin Strict on and off and Option Explicit on
and off For x As Integer = 0 To 5 ''Do Stuff Next -- -iwdu15 Hello Miro,
I've only tested this on VB6 and VB.Net on 2.0 framework.. Including the indexer in your Next statement drasticly decreases performance in long-running loops. You certainly wont notice a degredation on low to moderate interations (say, less than 250,000). -Boo Show quoteHide quote > Im using VB2003 and i just pulled an example out of the book that says > this: > > "Note: also that you can decalre the index variable in a For Loop > using the optional AS datatype clause, as long as the index variable > isnt already declared eslewhere. ( This is new to Visual Basic.net > 2003 ) > > It then gives the example : > > For intLoopIndex As Integer = 0 To 1 > 'This next line i have dummy'd down cause they use it to print an > array > element so like Foo( intLoopIndex ) > Console.WriteLine("Hello") > Next intLoopIndex > It does not mention having option strict on and option explicit on. > I have > them both on. > My simple solution is to just dim it before, cause it complaines that > intLoopIndex is not declared. > Im assuming its either because of the Option Strict and Option > Explicit and not a typo ( somehow ) in the book. > > Miro >
Show quote
Hide quote
"Miro" <miron***@golden.net> wrote in message The example given is correct. The following compiles just fine in VB.net news:OmtiD3VzGHA.4396@TK2MSFTNGP04.phx.gbl... : : Im using VB2003 and i just pulled an example out of the book that says : this: : : "Note: also that you can decalre the index variable in a For Loop using : the : optional AS datatype clause, as long as the index variable isnt already : declared eslewhere. ( This is new to Visual Basic.net 2003 ) : : It then gives the example : : : For intLoopIndex As Integer = 0 To 1 : 'This next line i have dummy'd down cause they use it to print an array : element so like Foo( intLoopIndex ) : Console.WriteLine("Hello") : Next intLoopIndex : : It does not mention having option strict on and option explicit on. I : have : them both on. : My simple solution is to just dim it before, cause it complaines that : intLoopIndex is not declared. : : Im assuming its either because of the Option Strict and Option Explicit : and not a typo ( somehow ) in the book. : : Miro 2.0: '---------------------------------------- Option Strict Imports System Public Module [module] Public Sub Main() Dim Arr(1) As String Arr(0) = "Hello" Arr(1) = "World" For intLoopIndex As Integer = 0 To 1 Console.WriteLine(Arr(intLoopIndex)) Next intLoopIndex End Sub End Module '---------------------------------------- Ralf -- -- ---------------------------------------------------------- * ^~^ ^~^ * * _ {~ ~} {~ ~} _ * * /_``>*< >*<''_\ * * (\--_)++) (++(_--/) * ---------------------------------------------------------- There are no advanced students in Aikido - there are only competent beginners. There are no advanced techniques - only the correct application of basic principles. Attached is a jpg with my mouse overs of the same code you have.
Maybe I have to download a version upgrade on my vb.net ? Its an old version of 2003, Its not a big deal, i just wanted to see if it really was possible. I guess Ill just have to Dim :-) Miro Show quoteHide quote "_AnonCoward" <abc***@uvwxyz.com> wrote in message [attached file: for_next_error.JPG]news:Y_MJg.711$Md4.571@tornado.southeast.rr.com... > > "Miro" <miron***@golden.net> wrote in message > news:OmtiD3VzGHA.4396@TK2MSFTNGP04.phx.gbl... > : > : Im using VB2003 and i just pulled an example out of the book that says > : this: > : > : "Note: also that you can decalre the index variable in a For Loop using > : the > : optional AS datatype clause, as long as the index variable isnt already > : declared eslewhere. ( This is new to Visual Basic.net 2003 ) > : > : It then gives the example : > : > : For intLoopIndex As Integer = 0 To 1 > : 'This next line i have dummy'd down cause they use it to print an array > : element so like Foo( intLoopIndex ) > : Console.WriteLine("Hello") > : Next intLoopIndex > : > : It does not mention having option strict on and option explicit on. I > : have > : them both on. > : My simple solution is to just dim it before, cause it complaines that > : intLoopIndex is not declared. > : > : Im assuming its either because of the Option Strict and Option Explicit > : and not a typo ( somehow ) in the book. > : > : Miro > > > The example given is correct. The following compiles just fine in VB.net > 2.0: > > '---------------------------------------- > Option Strict > > Imports System > > Public Module [module] > Public Sub Main() > > Dim Arr(1) As String > Arr(0) = "Hello" > Arr(1) = "World" > > For intLoopIndex As Integer = 0 To 1 > Console.WriteLine(Arr(intLoopIndex)) > Next intLoopIndex > > End Sub > End Module > '---------------------------------------- > > > Ralf > -- > -- > ---------------------------------------------------------- > * ^~^ ^~^ * > * _ {~ ~} {~ ~} _ * > * /_``>*< >*<''_\ * > * (\--_)++) (++(_--/) * > ---------------------------------------------------------- > There are no advanced students in Aikido - there are only > competent beginners. There are no advanced techniques - > only the correct application of basic principles. > > And by pasting my pic in the previous post, I have just realized I am using
2002. I should RTFS Sorry for the post. Miro Show quoteHide quote "Miro" <miron***@golden.net> wrote in message news:uA0%23usXzGHA.4580@TK2MSFTNGP05.phx.gbl... > Attached is a jpg with my mouse overs of the same code you have. > > Maybe I have to download a version upgrade on my vb.net ? > Its an old version of 2003, > Its not a big deal, i just wanted to see if it really was possible. > > I guess Ill just have to Dim :-) > > Miro > > > "_AnonCoward" <abc***@uvwxyz.com> wrote in message > news:Y_MJg.711$Md4.571@tornado.southeast.rr.com... >> >> "Miro" <miron***@golden.net> wrote in message >> news:OmtiD3VzGHA.4396@TK2MSFTNGP04.phx.gbl... >> : >> : Im using VB2003 and i just pulled an example out of the book that says >> : this: >> : >> : "Note: also that you can decalre the index variable in a For Loop using >> : the >> : optional AS datatype clause, as long as the index variable isnt already >> : declared eslewhere. ( This is new to Visual Basic.net 2003 ) >> : >> : It then gives the example : >> : >> : For intLoopIndex As Integer = 0 To 1 >> : 'This next line i have dummy'd down cause they use it to print an array >> : element so like Foo( intLoopIndex ) >> : Console.WriteLine("Hello") >> : Next intLoopIndex >> : >> : It does not mention having option strict on and option explicit on. I >> : have >> : them both on. >> : My simple solution is to just dim it before, cause it complaines that >> : intLoopIndex is not declared. >> : >> : Im assuming its either because of the Option Strict and Option Explicit >> : and not a typo ( somehow ) in the book. >> : >> : Miro >> >> >> The example given is correct. The following compiles just fine in VB.net >> 2.0: >> >> '---------------------------------------- >> Option Strict >> >> Imports System >> >> Public Module [module] >> Public Sub Main() >> >> Dim Arr(1) As String >> Arr(0) = "Hello" >> Arr(1) = "World" >> >> For intLoopIndex As Integer = 0 To 1 >> Console.WriteLine(Arr(intLoopIndex)) >> Next intLoopIndex >> >> End Sub >> End Module >> '---------------------------------------- >> >> >> Ralf >> -- >> -- >> ---------------------------------------------------------- >> * ^~^ ^~^ * >> * _ {~ ~} {~ ~} _ * >> * /_``>*< >*<''_\ * >> * (\--_)++) (++(_--/) * >> ---------------------------------------------------------- >> There are no advanced students in Aikido - there are only >> competent beginners. There are no advanced techniques - >> only the correct application of basic principles. >> >> > > > > And by pasting my pic in the previous post, I have just realized I am That would do it. The inline declaration wasn't allowed until 2003. Don't > using 2002. you hate answering your own questions... Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx Geeze as soon as i Posted it I realized it.
I looked at the "about box" 3 times, and to think I didnt even notice it even as I made the jpg. But sure enough...once I hit send it hit me. I was playing with VB.Express 2003 on another machine that came on a cd with a different book, and totally messed myself up. Thanks for the posts everyone. As suspected - Book is correct - and Im a Dumb Bum. Miro Show quoteHide quote "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message news:24f81e8fd5158c89bbb9fbe1c7d@msnews.microsoft.com... >> And by pasting my pic in the previous post, I have just realized I am >> using 2002. > > That would do it. The inline declaration wasn't allowed until 2003. Don't > you hate answering your own questions... > Jim Wooley > http://devauthority.com/blogs/jwooley/default.aspx > > VB Express is verison 2.0 aka 2005 not 2003 ;)
Show quoteHide quote "Miro" <miron***@golden.net> wrote in message news:OZZoyuczGHA.3440@TK2MSFTNGP06.phx.gbl... > Geeze as soon as i Posted it I realized it. > I looked at the "about box" 3 times, and to think I didnt even notice it > even as I made the jpg. > But sure enough...once I hit send it hit me. > > I was playing with VB.Express 2003 on another machine that came on a cd > with a different book, > and totally messed myself up. > > Thanks for the posts everyone. > As suspected - Book is correct - and Im a Dumb Bum. > > Miro > > "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message > news:24f81e8fd5158c89bbb9fbe1c7d@msnews.microsoft.com... >>> And by pasting my pic in the previous post, I have just realized I am >>> using 2002. >> >> That would do it. The inline declaration wasn't allowed until 2003. >> Don't you hate answering your own questions... >> Jim Wooley >> http://devauthority.com/blogs/jwooley/default.aspx >> >> > > No I think it would be a 2003 version.
It came with a book called: Microsoft Visual Basic.net Reloaded by Diane Zak, It comes iwth a Product Key and on the cd it says 2003 ( Personally I think the book isnt worth it.) but it is a 2003 version. I bought 3 books and the one that has helped me out the most is Sams Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days -for a good reference. Ps...it has been more than 21 days ;) Miro. Show quoteHide quote "Smokey Grindel" <nospam@nospam.com> wrote in message news:ur0%237fezGHA.2516@TK2MSFTNGP06.phx.gbl... > VB Express is verison 2.0 aka 2005 not 2003 ;) > > "Miro" <miron***@golden.net> wrote in message > news:OZZoyuczGHA.3440@TK2MSFTNGP06.phx.gbl... >> Geeze as soon as i Posted it I realized it. >> I looked at the "about box" 3 times, and to think I didnt even notice it >> even as I made the jpg. >> But sure enough...once I hit send it hit me. >> >> I was playing with VB.Express 2003 on another machine that came on a cd >> with a different book, >> and totally messed myself up. >> >> Thanks for the posts everyone. >> As suspected - Book is correct - and Im a Dumb Bum. >> >> Miro >> >> "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message >> news:24f81e8fd5158c89bbb9fbe1c7d@msnews.microsoft.com... >>>> And by pasting my pic in the previous post, I have just realized I am >>>> using 2002. >>> >>> That would do it. The inline declaration wasn't allowed until 2003. >>> Don't you hate answering your own questions... >>> Jim Wooley >>> http://devauthority.com/blogs/jwooley/default.aspx >>> >>> >> >> > > Hello Miro,
That may be, but Smokey is correct.. the "Express" versions of visual studio are version 2005 and run against the 2.0 framework. There was no "Express" version for 2003 / 1.x framework (unless you count notepad and the .NET SDK). -Boo Show quoteHide quote > No I think it would be a 2003 version. > > It came with a book called: > > Microsoft Visual Basic.net Reloaded by Diane Zak, It comes iwth a > Product Key and on the cd it says 2003 > > ( Personally I think the book isnt worth it.) but it is a 2003 > version. > > I bought 3 books and the one that has helped me out the most is Sams > Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days -for a good > reference. > > Ps...it has been more than 21 days ;) > > Miro. > > "Smokey Grindel" <nospam@nospam.com> wrote in message > news:ur0%237fezGHA.2516@TK2MSFTNGP06.phx.gbl... > >> VB Express is verison 2.0 aka 2005 not 2003 ;) >> >> "Miro" <miron***@golden.net> wrote in message >> news:OZZoyuczGHA.3440@TK2MSFTNGP06.phx.gbl... >> >>> Geeze as soon as i Posted it I realized it. >>> I looked at the "about box" 3 times, and to think I didnt even >>> notice it >>> even as I made the jpg. >>> But sure enough...once I hit send it hit me. >>> I was playing with VB.Express 2003 on another machine that came on a >>> cd >>> with a different book, >>> and totally messed myself up. >>> Thanks for the posts everyone. >>> As suspected - Book is correct - and Im a Dumb Bum. >>> Miro >>> >>> "Jim Wooley" <jimNOSPAMwooley@hotmail.com> wrote in message >>> news:24f81e8fd5158c89bbb9fbe1c7d@msnews.microsoft.com... >>> >>>>> And by pasting my pic in the previous post, I have just realized I >>>>> am using 2002. >>>>> >>>> That would do it. The inline declaration wasn't allowed until 2003. >>>> Don't you hate answering your own questions... >>>> Jim Wooley >>>> http://devauthority.com/blogs/jwooley/default.aspx Miro wrote:
Show quoteHide quote > Im using VB2003 and i just pulled an example out of the book that says this: VB.NET 2003> > "Note: also that you can decalre the index variable in a For Loop using the > optional AS datatype clause, as long as the index variable isnt already > declared eslewhere. ( This is new to Visual Basic.net 2003 ) > > It then gives the example : > > For intLoopIndex As Integer = 0 To 1 > 'This next line i have dummy'd down cause they use it to print an array > element so like Foo( intLoopIndex ) > Console.WriteLine("Hello") > Next intLoopIndex > Option Strict On Option Explicit On Imports System Module Module1 Sub Main() For i As Integer = 0 To 10 Console.WriteLine(i) Next End Sub End Module Works just peachy... Now, it would be an error if you tried to access i out side of the for loop. -- Tom Shelton
Show quote
Hide quote
"Miro" <miron***@golden.net> schrieb: Are you sure you are using VS.NET/VB.NET 2003 or newer? The inline syntax > Im using VB2003 and i just pulled an example out of the book that says > this: > > "Note: also that you can decalre the index variable in a For Loop using > the optional AS datatype clause, as long as the index variable isnt > already declared eslewhere. ( This is new to Visual Basic.net 2003 ) > > It then gives the example : > > For intLoopIndex As Integer = 0 To 1 > 'This next line i have dummy'd down cause they use it to print an array > element so like Foo( intLoopIndex ) > Console.WriteLine("Hello") > Next intLoopIndex > > It does not mention having option strict on and option explicit on. I > have them both on. > My simple solution is to just dim it before, cause it complaines that > intLoopIndex is not declared. is not supported by previous versions of Visual Basic. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
API FindFirstFile\FindNextFile vs GetFiles
How to Type cast ArrayList items to class objects Best practices for creating a "wizard" VB 2005 with Active Directory Return DataRow Application quit after button click use varible value in include file using com-port in VB.net Strange Datagrid Behavior How to use Resource files in VS 2005? |
|||||||||||||||||||||||