C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Tips in VB.NET - Tip #6


Posted Date: 21 Mar 2004    Resource Type: Articles    Category: .NET Framework
Author: Sadha SivamMember Level: Gold    
Rating: 1 out of 5Points: 5



Tips in VB.NET - Tip #6

In this tip we see about With....End With.

I know most of you atleast would have heard about With....End With block. But Most of us will not be using it.

I found it to be very useful.

With....End With

With...End statement is used to perform a series of statements on a specified object without requalifying the name of the object.

For example, to change a number of different properties/function on a single object, place the property assignment statements within the With...End With, referring to the object once instead of referring to it with each property assignment.

Now, lets modify the function which we defined in our Tip#3


Public Function ReturnDateInfoCollection() As System.Collections.Hashtable
Dim ht As New Hashtable()
ht.Add("Day", Format(DateTime.Today, "dddd"))
ht.Add("Month", Month(DateTime.Today))
ht.Add("Hour", Hour(DateTime.Now))
ht.Add("Minute", Minute(DateTime.Now))
ht.Add("Second", Second(DateTime.Now))
Return ht
End Function


Now, lets use the With....End With in the above function.


Public Function ReturnDateInfoCollection() As System.Collections.Hashtable
Dim ht As New Hashtable()
With ht
.Add("Day", Format(DateTime.Today, "dddd"))
.Add("Month", Month(DateTime.Today))
.Add("Hour", Hour(DateTime.Now))
.Add("Minute", Minute(DateTime.Now))
.Add("Second", Second(DateTime.Now))
End With
Return ht
End Function


I leave the remaing to you. There are many more things in this With...End With statement and they can be more useful to you. Explore and try to find some ways how you can make it more useful.




Please send me your suggestion and feedback to sadhasivam1981@yahoo.com.

Please vist http://sadhasivam.t35.com



Every Features has a purpose

Finding it leads to great benefits








Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Tips in VB.NET - Tip #5
Previous Resource: Tips in VB.NET - Tip #7
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use