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 485 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.
  • C Colborne_Greg

    Considering the missing connection between me knowing C# can get away without using the with word, proves its problems. The with keyword gets the coder in a mindset.

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

    My dislike of with (also in Pascal I think) is that the only place I would have liked to use it, it won't work... If I have two things (not necessarily the same type), and I want to copy a number of values (not necessarily all the values) between them:

    thing1.fieldM = thing2.fieldP ;
    thing1.fieldD = thing2.fieldQ ;
    ...

    I want a with that will allow me to do something like:

    with ( thing1 , thing2 )
    {
    fieldM = fieldP ;
    fieldD = fieldQ ;
    ...
    }

    That would be usefull. As it stands, with is pointless (in my opinion) so I have never used it. However, one could use something like:

    {
    var src = thing1 ;
    var dst = thing2 ;

    dst.fieldM = src.fieldP ;
    dst.fieldD = src.fieldQ ;
    ...
    }

    which is almost a good. :shrug:

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

    C 1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      That may be part of the problem...

      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 – ∞)

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

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

      OriginalGriffO 1 Reply Last reply
      0
      • C Colborne_Greg

        Without the with operator C# has a smaller scope

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

        Sorry as Bob has pointed out, this sort of argument needs more research. many have also pointed out from the .net framework that C# doesn't need the With keyword. There are many other keywords if you looked and were pedantic enough C# doesn't use but slight change / merge of keywords you could achieve the same thing. relax and enjoy the lounge they don't really care what language you code in.

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

        C 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

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

          Wow. Dude. If you're going to say something like that, make sure you're exposed to more languages first.

          C 1 Reply Last reply
          0
          • C Colborne_Greg

            That's just laziness and the expectation that it works 100% of the time

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #55

            ..and also something that happens quite often in VB. And no, one cannot call it lazy - the author of said snippet included TWO handlers to swallow the exceptions. That's not lazy, that's extra work. It could be improved by simply REMOVING the check completely.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            C 1 Reply Last reply
            0
            • C Colborne_Greg

              visual basic takes less skill to get the job done

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

              If it's in VB, it isn't "done". :laugh:

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

              C 1 Reply Last reply
              0
              • C Colborne_Greg

                I should have left out the try catch

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

                Or handled it.

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

                C 1 Reply Last reply
                0
                • P PIEBALDconsult

                  My dislike of with (also in Pascal I think) is that the only place I would have liked to use it, it won't work... If I have two things (not necessarily the same type), and I want to copy a number of values (not necessarily all the values) between them:

                  thing1.fieldM = thing2.fieldP ;
                  thing1.fieldD = thing2.fieldQ ;
                  ...

                  I want a with that will allow me to do something like:

                  with ( thing1 , thing2 )
                  {
                  fieldM = fieldP ;
                  fieldD = fieldQ ;
                  ...
                  }

                  That would be usefull. As it stands, with is pointless (in my opinion) so I have never used it. However, one could use something like:

                  {
                  var src = thing1 ;
                  var dst = thing2 ;

                  dst.fieldM = src.fieldP ;
                  dst.fieldD = src.fieldQ ;
                  ...
                  }

                  which is almost a good. :shrug:

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

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

                  I would not hire you sorry. The reason you can not use the with operator in such a fashion is scope

                  Z T 2 Replies 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

                    E Offline
                    E Offline
                    ed welch
                    wrote on last edited by
                    #59

                    Nothing against vb, but catching exceptions and then not handling them is epic fail for me, not "beauty and elegance".

                    C 1 Reply Last reply
                    0
                    • L Lost User

                      ..and also something that happens quite often in VB. And no, one cannot call it lazy - the author of said snippet included TWO handlers to swallow the exceptions. That's not lazy, that's extra work. It could be improved by simply REMOVING the check completely.

                      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

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

                      Most of that code is autocompleted also the inside catch is to ensure the loop continues

                      L 1 Reply Last reply
                      0
                      • E ed welch

                        Nothing against vb, but catching exceptions and then not handling them is epic fail for me, not "beauty and elegance".

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

                        Running through a database there are some times bad records. I don't want them crashing the program nor do I care at this point what the problem is

                        1 Reply Last reply
                        0
                        • B BobJanova

                          With, when used appropriately, aids clarity just by removing characters – if you have to read past "SomeLongObjectName." at the start of every line you won't actually see the important word. When used badly (so you don't know whether the tokens on the line are part of the with'd object or locals or something else) it makes things worse. I've used with in ActionScript, usually for graphics code which is doing nothing but a bunch of calls to lineTo, moveTo, setBitmapFill etc, and (imo anyway) not having "e.graphics." on every line makes that clearer.

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

                          BobJanova wrote:

                          doing nothing but a bunch of calls to lineTo, moveTo, setBitmapFill etc, and (imo anyway) not having "e.graphics." on every line makes that clearer

                          Howsabout writing a function then? Now I'm wondering wether or not an anomymous function would do that...

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

                          B 1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            If it's in VB, it isn't "done". :laugh:

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

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

                            Whats not in visual basic?

                            1 Reply Last reply
                            0
                            • M mikepwilson

                              Wow. Dude. If you're going to say something like that, make sure you're exposed to more languages first.

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

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

                              M 1 Reply Last reply
                              0
                              • J Jorgen Andersson

                                Or handled it.

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

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

                                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 R S 3 Replies Last reply
                                0
                                • S Simon_Whale

                                  Sorry as Bob has pointed out, this sort of argument needs more research. many have also pointed out from the .net framework that C# doesn't need the With keyword. There are many other keywords if you looked and were pedantic enough C# doesn't use but slight change / merge of keywords you could achieve the same thing. relax and enjoy the lounge they don't really care what language you code in.

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

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

                                  S B 2 Replies Last reply
                                  0
                                  • 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
                                          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