473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Shorter Declaration when using For Each

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
Nov 21 '05 #1
7 964
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" <mo*********@suretar.reverse> wrote in message
news:%2****************@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
Nov 21 '05 #2
Oh that's very nice, thank you so much!

"Gerry O'Brien [MVP]" <gk******@hotmail.com> wrote in message news:uW**************@TK2MSFTNGP11.phx.gbl...
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" <mo*********@suretar.reverse> wrote in message
news:%2****************@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

Nov 21 '05 #3
For Each adminuser As String In adminusers
If username = adminuser Then
m_admin = True
End If
Next

Tom Dacon
Dacon Software Consulting

"Raterus" <mo*********@suretar.reverse> wrote in message
news:%2****************@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
Nov 21 '05 #4
FYI, this was added to NET 1.1 Framework. Or is it just VB 2003 and not
necessarily the framework...

Greg

"Gerry O'Brien [MVP]" <gk******@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl...
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" <mo*********@suretar.reverse> wrote in message
news:%2****************@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

Nov 21 '05 #5
* "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> scripsit:
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...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6
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
Nov 21 '05 #7
Good catch Cor!

Greg

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
5
by: Nomak | last post by:
Hello all, i have two template classes which needs each other. I tried to write some fwd decl / decl / impl in a good way but i can't get it to compile. Explanations: - .hh files are for...
6
by: Daniel Nichols | last post by:
I've noticed that in a C module (.c, .h file combination) that if you create a function's definition before it is used in other functions than a declaration is not necessary. I believe if the...
3
by: Wild Wind | last post by:
Hello, I made a post relating to this issue a while back, but I haven't received any answer, so here I am again. I am writing a mixed C++ dll which uses the following declaration: typedef...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
1
by: Daikide | last post by:
I need average for my program. And I'm using it multiple time in my program. I'm doing this in PVSS: So say average float is 2.0013005 (FOR EXAMPLE) but the number in the end can be higher......
3
by: skanemupp | last post by:
is there anyway to make this shorter? i hate having these big blocks of similar-looking code, very unaesthetic. maybe doesnt matter good-code-wise? anyway can i make some function that makes this...
4
by: raylopez99 | last post by:
Please consider the below and how to make name references shorter-- there has to be a way. RL using System; namespace MyNamesSpace1 { class ManagerClass
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.