Shorter Declaration when using For Each

  • Thread starter Thread starter Raterus
  • Start date Start date
R

Raterus

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
 
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


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
 
For Each adminuser As String In adminusers
If username = adminuser Then
m_admin = True
End If
Next

Tom Dacon
Dacon Software Consulting

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
 
FYI, this was added to NET 1.1 Framework. Or is it just VB 2003 and not
necessarily the framework...

Greg
 
* "Greg Burns said:
FYI, this was added to NET 1.1 Framework. Or is it just VB 2003 and not
necessarily the framework...

It's the VB.NET 2003 programming language...
 
In addition to the others, not making the syntax faster however your program

\\\
For Each adminuser As String in adminusers
If username = adminuser Then
m_admin = True
exit For
End If
Next
///
I hope this helps?

:-)

Cor
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top