Results 1 to 6 of 6

Thread: [RESOLVED] [2.0] vb6 "With" Statement

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Bonny Scotland
    Posts
    141

    Resolved [RESOLVED] [2.0] vb6 "With" Statement

    Hi,

    I recall using the With statement in vb6 when i wanted to set a number of variables relating to the same object, something like this:

    Code:
    with tempObject
        .Name = "name";
        .Value = "Bob";
    end with
    Is there a c# equivelant to this and if so could somenbody let me know what it is please.

    Many thanks,

    Grant

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2.0] vb6 "With" Statement

    No there isn't any With in C#.

    These should be of some interest
    http://msdn.microsoft.com/vcsharp/pr...withstatement/


    And this one is good
    http://www.programmersheaven.com/art...rik/clause.htm
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Bonny Scotland
    Posts
    141

    Re: [2.0] vb6 "With" Statement

    Thanks for this.

    This is indeed useful. Unfortunate though that it isn't implemented.


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] [2.0] vb6 "With" Statement

    The addition of a 'with' key word would be of no practical use whatsoever. The two advantages of using 'With' in VB are reduced typing and reduced need to re-evaluate the same properties repeatedly. The first is negated by Intellisense and copy-and-paste and the second can be achieved simply by declaring a local variable. One problem with the 'With' block in VB is that people tend to use them in places that they shouldn't and end up making their code less readable rather than the other way around.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] [2.0] vb6 "With" Statement

    Don't fret, it's just having to type a few more characters on each line. Keyboards aren't very expensive these days.

  6. #6
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: [RESOLVED] [2.0] vb6 "With" Statement

    In addition to the other comments, AutoComplete is much better in C# 2005 than in VB (I rarely have to type an entire identifier), so you shouldn't miss 'With' that much.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width