Re: Shorter Declaration when using For Each

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Gerry O'Brien [MVP] (gkcomput_at_hotmail.com)
Date: 09/08/04


Date: Wed, 8 Sep 2004 13:49:38 -0300

Certainly, .NET now allows you to do this;

For Each adminuser As String in adminusers
    If username = adminuser Then
        m_admin = True
    End If
Next

-- 
Gerry O'Brien [MVP]
Visual Basic .NET
"Raterus" <moc.liamtoh@suretar.reverse> wrote in message 
news:%23fzmVEclEHA.3712@TK2MSFTNGP15.phx.gbl...
Hi, is there a way I can avoid having to declare my variable I use when 
using a For Each loop?
            Dim adminuser As String    'I'd like to get rid of this line and 
just declare it all on the next line
            For Each adminuser In adminusers
                If username = adminuser Then
                    m_admin = True
                End If
            Next
Thanks,
--Michael 


Relevant Pages

  • Re: Shorter Declaration when using For Each
    ... > For Each adminuser As String in adminusers ... > using a For Each loop? ... > just declare it all on the next line ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Shorter Declaration when using For Each
    ... not making the syntax faster however your program ... For Each adminuser As String in adminusers ... If username = adminuser Then ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Shorter Declaration when using For Each
    ... this was added to NET 1.1 Framework. ... Greg ... > For Each adminuser As String in adminusers ... > and just declare it all on the next line ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Shorter Declaration when using For Each
    ... Good catch Cor! ... > In addition to the others, not making the syntax faster however your ... > For Each adminuser As String in adminusers ...
    (microsoft.public.dotnet.languages.vb)