Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Visual Basic needs more credit

Visual Basic needs more credit

Scheduled Pinned Locked Moved The Lounge
206 Posts 32 Posters 36 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Kenneth Haugland

    With his pants on fire :laugh: I read somewhere that there are things that VB can do and C# can't an vice versa though... Think it had something to do with Errorhandling ?

    D Offline
    D Offline
    Duncan Edwards Jones
    wrote on last edited by
    #67

    Inline XML? Does C# have that yet?

    K 1 Reply Last reply
    0
    • C Colborne_Greg

      6 years of school, granted my studies are out of date by 5 years

      M Offline
      M Offline
      mikepwilson
      wrote on last edited by
      #68

      "with" isn't particularly unique or interesting. There's a lot of functionality in a few lines. But you can stack up languages like cordwood that have lambdas, currying and/or templating features that would reduce the footprint of that code far more. It's awesome to be excited about a language. Lord knows I've spent most of the last 40 years that way. But do yourself a favor, take this post and put it in a calendar item marked 5 years from now and come back and look at it then. Visual Basic has come a long way since the VB3 days. But it's a very very long way away from winning awards for elegance.

      C 1 Reply Last reply
      0
      • C Colborne_Greg

        VB New image with {.height = height} C# New image {height = height} second one fails

        S Offline
        S Offline
        Simon_Whale
        wrote on last edited by
        #69

        No as you would of written it like this VB.NET Version

        New image With
        {
        .height = height
        }

        C# Version, in the C# version the With Keyword is ommited

        new image { height = this.height }

        Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

        C P 2 Replies Last reply
        0
        • L Lost User

          Are you still opposed to using (the namespace one, not the disposing one or the alias one) as well?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #70

          Yes. And I really don't like that Extension Methods require the using directive. Very powerful are aliases though. Recently I used an alias to resolve a namespace conflict, rather than have globall:: scattered throughout some code:

          namespace PIEBALD.Data.MySql
          {
          using MySqlClient=global::MySql.Data.MySqlClient ;

          public sealed class DatabaseInfo : PIEBALD.Data.DatabaseInfo<MySqlClient.MySqlDbType>

          You'll never get very far if all you do is follow instructions.

          C 1 Reply Last reply
          0
          • D Duncan Edwards Jones

            Inline XML? Does C# have that yet?

            K Offline
            K Offline
            Kenneth Haugland
            wrote on last edited by
            #71

            Don't know...

            1 Reply Last reply
            0
            • C Colborne_Greg

              When dealing with a database, sometimes there are bad records. I meant for these try catches to be this way, as I don't care at this point why there would be problems in the data, all other errors are handled.

              J Offline
              J Offline
              Jorgen Andersson
              wrote on last edited by
              #72

              Then catch the DB errors and rethrow the rest.

              Wrong is evil and must be defeated. - Jeff Ello[^]

              C 1 Reply Last reply
              0
              • C Colborne_Greg

                That code would fail as the scopes would be confused

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #73

                No it wouldn't.


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                C 1 Reply Last reply
                0
                • C Colborne_Greg

                  this message is spam

                  Richard DeemingR Offline
                  Richard DeemingR Offline
                  Richard Deeming
                  wrote on last edited by
                  #74

                  Colborne_Greg wrote:

                  this message is spam

                  OK, at least you're being honest about it. As requested, I've reported your message as spam. Happy now? ;P


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                  C 1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    Colborne_Greg wrote:

                    this message is spam

                    OK, at least you're being honest about it. As requested, I've reported your message as spam. Happy now? ;P


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    C Offline
                    C Offline
                    Colborne_Greg
                    wrote on last edited by
                    #75

                    Advertising your other post is spam

                    Richard DeemingR R 2 Replies Last reply
                    0
                    • J Jorgen Andersson

                      Then catch the DB errors and rethrow the rest.

                      Wrong is evil and must be defeated. - Jeff Ello[^]

                      C Offline
                      C Offline
                      Colborne_Greg
                      wrote on last edited by
                      #76

                      I'm not using SQL

                      1 Reply Last reply
                      0
                      • S Simon_Whale

                        No as you would of written it like this VB.NET Version

                        New image With
                        {
                        .height = height
                        }

                        C# Version, in the C# version the With Keyword is ommited

                        new image { height = this.height }

                        Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

                        C Offline
                        C Offline
                        Colborne_Greg
                        wrote on last edited by
                        #77

                        So now instead of with I need this. And I would have to write this over and over and over

                        P 1 Reply Last reply
                        0
                        • Richard DeemingR Richard Deeming

                          No it wouldn't.


                          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                          C Offline
                          C Offline
                          Colborne_Greg
                          wrote on last edited by
                          #78

                          VB New image with {.height = height} C# New image {height = height} second one fails

                          Richard DeemingR 1 Reply Last reply
                          0
                          • C Colborne_Greg

                            I think that Visual Basic should be shown off for its beauty and elegance. Here is a sample of what it can do - that no other language can do:

                            Private Sub AlbumListPopulate()
                            Try
                            AlbumsList.ItemsSource = New List(Of Image)

                                For Each AlbumName In Pictures.Albums
                                    Try
                                        AlbumsList.ItemsSource.Add \_
                                            (
                                                New Image With
                                                {
                                                    .Height = 150,
                                                    .Width = 150,
                                                    .Source = RotateStream \_
                                                    (
                                                        Pictures.Album(AlbumName).Picture,
                                                        Pictures.Album(AlbumName).Angle
                                                    )
                                                }
                                            )
                                    Catch
                                    End Try
                                Next
                            Catch
                            End Try
                            

                            End Sub

                            G Offline
                            G Offline
                            gardnerp
                            wrote on last edited by
                            #79

                            It's just not that elegant to have two separate try/catch blocks that completely hide the error and never handle it. And everything you have there can be done in C# as well.

                            C 1 Reply Last reply
                            0
                            • M mikepwilson

                              "with" isn't particularly unique or interesting. There's a lot of functionality in a few lines. But you can stack up languages like cordwood that have lambdas, currying and/or templating features that would reduce the footprint of that code far more. It's awesome to be excited about a language. Lord knows I've spent most of the last 40 years that way. But do yourself a favor, take this post and put it in a calendar item marked 5 years from now and come back and look at it then. Visual Basic has come a long way since the VB3 days. But it's a very very long way away from winning awards for elegance.

                              C Offline
                              C Offline
                              Colborne_Greg
                              wrote on last edited by
                              #80

                              The unique part about the with; is that it is simple - easy to learn, little if no problems to overcome just by using the structure.

                              1 Reply Last reply
                              0
                              • C Colborne_Greg

                                Advertising your other post is spam

                                Richard DeemingR Offline
                                Richard DeemingR Offline
                                Richard Deeming
                                wrote on last edited by
                                #81

                                No, posting links to unrelated sites or commercial products is spam. Telling a user that you've already replied to their comments in another post on the same site is not. Falsely accusing other members of posting spam, however, would count as abuse. :suss:


                                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                C 1 Reply Last reply
                                0
                                • G gardnerp

                                  It's just not that elegant to have two separate try/catch blocks that completely hide the error and never handle it. And everything you have there can be done in C# as well.

                                  C Offline
                                  C Offline
                                  Colborne_Greg
                                  wrote on last edited by
                                  #82

                                  the try catches were not suppose to be illustrated as a bonus, and a laziness on my part, but intentional with how my code works

                                  1 Reply Last reply
                                  0
                                  • Richard DeemingR Richard Deeming

                                    No, posting links to unrelated sites or commercial products is spam. Telling a user that you've already replied to their comments in another post on the same site is not. Falsely accusing other members of posting spam, however, would count as abuse. :suss:


                                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                    C Offline
                                    C Offline
                                    Colborne_Greg
                                    wrote on last edited by
                                    #83

                                    In my defense I got this exact post 3 times without validating you only posted it once

                                    1 Reply Last reply
                                    0
                                    • C Colborne_Greg

                                      VB New image with {.height = height} C# New image {height = height} second one fails

                                      Richard DeemingR Offline
                                      Richard DeemingR Offline
                                      Richard Deeming
                                      wrote on last edited by
                                      #84

                                      Colborne_Greg wrote:

                                      second one fails

                                      No, it doesn't. https://dotnetfiddle.net/J0N7Mm[^]

                                      using System;

                                      public class Program
                                      {
                                      public static void Main()
                                      {
                                      int height = 100;
                                      var image = new Image { height = height };
                                      Console.WriteLine("The image's height is {0}.", image.height);
                                      }
                                      }

                                      public class Image
                                      {
                                      public int height { get; set; }
                                      }

                                      Output: The image's height is 100.


                                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                      C 2 Replies Last reply
                                      0
                                      • Richard DeemingR Richard Deeming

                                        Colborne_Greg wrote:

                                        second one fails

                                        No, it doesn't. https://dotnetfiddle.net/J0N7Mm[^]

                                        using System;

                                        public class Program
                                        {
                                        public static void Main()
                                        {
                                        int height = 100;
                                        var image = new Image { height = height };
                                        Console.WriteLine("The image's height is {0}.", image.height);
                                        }
                                        }

                                        public class Image
                                        {
                                        public int height { get; set; }
                                        }

                                        Output: The image's height is 100.


                                        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                        C Offline
                                        C Offline
                                        Colborne_Greg
                                        wrote on last edited by
                                        #85

                                        damn

                                        A 1 Reply Last reply
                                        0
                                        • C Colborne_Greg

                                          What problem? People with less skill are more focused on getting the job done, then writing cool useless code.

                                          OriginalGriffO Offline
                                          OriginalGriffO Offline
                                          OriginalGriff
                                          wrote on last edited by
                                          #86

                                          The problem is that "people with less skill" assume that a "ooh shiny" language feature is cool at all. With is a PITA - it doesn't improve readability, it obfuscates it slightly and just makes it slightly shorter to type.

                                          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                          C 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups