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. Seven Steps to Improving Your VB Code

Seven Steps to Improving Your VB Code

Scheduled Pinned Locked Moved The Lounge
csharpc++comquestion
42 Posts 18 Posters 0 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.
  • S Shog9 0

    Heh. Nice one, Rama... With the possible exception of the tree, every control in that shot is custom. :)

    every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

    R Offline
    R Offline
    Rama Krishna Vavilala
    wrote on last edited by
    #17

    Here is another which has your favorite UI technology (Same app) Screenshot2

    Co-Author ASP.NET AJAX in Action

    S 1 Reply Last reply
    0
    • P Phil Harding

      Marc Clifton wrote:

      I can always tell a VB app because of the funky colors, large fonts, and odd UI

      Yeah, it seems the same for Delphi too, why is that I wonder :confused:


      - "I'm not lying, I'm just writing fiction with my mouth"

      Phil Harding.
      myBlog [^] | mySite [^]

      D Offline
      D Offline
      Dan Neely
      wrote on last edited by
      #18

      Phil Harding wrote:

      Yeah, it seems the same for Delphi too, why is that I wonder

      That's a diffent issue than VB's anti-design patterns. With borland tools you have the fact that Borland was convinced they could make better controls than MS, as a result most (all?) of their 'standard' controls are custom not win32 basic constructs. As a result they always function subtlety different than standard.

      -- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer

      R J 2 Replies Last reply
      0
      • M Marc Clifton

        None of the above. :) Looks like you're using a DevExpress or Infragistics suite. (OK, that makes it .NET. But probably VB with a 3rd party control suite). Marc

        Thyme In The Country
        Interacx
        My Blog

        R Offline
        R Offline
        Rama Krishna Vavilala
        wrote on last edited by
        #19

        The correct answer is All of The Above:) 1. The main window tree view the MDI tabs all are C++/MFC. Uses CodeJock Library. 2. The top window "Bat Template" is actually a VB6 Control that hosts a WTL Tabs Control (custom built). All of these hosted as an ActiveX control in an MFC CView. 3. The bottom Grid is .NET Winforms DataGridView derived class written in C# hosted in an MFC CView derived class written in C++/CLI.

        Co-Author ASP.NET AJAX in Action

        M 1 Reply Last reply
        0
        • D Dan Neely

          Phil Harding wrote:

          Yeah, it seems the same for Delphi too, why is that I wonder

          That's a diffent issue than VB's anti-design patterns. With borland tools you have the fact that Borland was convinced they could make better controls than MS, as a result most (all?) of their 'standard' controls are custom not win32 basic constructs. As a result they always function subtlety different than standard.

          -- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer

          R Offline
          R Offline
          Rama Krishna Vavilala
          wrote on last edited by
          #20

          Even all the VB controls are not standard Win32 controls.

          Co-Author ASP.NET AJAX in Action

          1 Reply Last reply
          0
          • R Rama Krishna Vavilala

            Is something wrong? It's a test machine used to test Client and server.

            Co-Author ASP.NET AJAX in Action

            S Offline
            S Offline
            Shog9 0
            wrote on last edited by
            #21

            I just dislike the way that theme looks, and wouldn't bother going out of my way to enable it. :)

            every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

            1 Reply Last reply
            0
            • R Rama Krishna Vavilala

              The correct answer is All of The Above:) 1. The main window tree view the MDI tabs all are C++/MFC. Uses CodeJock Library. 2. The top window "Bat Template" is actually a VB6 Control that hosts a WTL Tabs Control (custom built). All of these hosted as an ActiveX control in an MFC CView. 3. The bottom Grid is .NET Winforms DataGridView derived class written in C# hosted in an MFC CView derived class written in C++/CLI.

              Co-Author ASP.NET AJAX in Action

              M Offline
              M Offline
              Marc Clifton
              wrote on last edited by
              #22

              Rama Krishna Vavilala wrote:

              The correct answer is All of The Above

              Nice! That must have been quite interesting to put all together. Marc

              Thyme In The Country
              Interacx
              My Blog

              R 1 Reply Last reply
              0
              • R Rama Krishna Vavilala

                Here is another which has your favorite UI technology (Same app) Screenshot2

                Co-Author ASP.NET AJAX in Action

                S Offline
                S Offline
                Shog9 0
                wrote on last edited by
                #23

                Ah, very nice. But an odd choice of colors... was this perhaps originally designed on a machine where those shades of grey matched?

                every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                R 1 Reply Last reply
                0
                • S Shog9 0

                  Ah, very nice. But an odd choice of colors... was this perhaps originally designed on a machine where those shades of grey matched?

                  every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                  R Offline
                  R Offline
                  Rama Krishna Vavilala
                  wrote on last edited by
                  #24

                  Shog9 wrote:

                  was this perhaps originally designed on a machine where those shades of grey matched?

                  No it was end-user designed screen (The app has an HTML form designer built into it which allows end users to design screens). He might be using a different theme in the application.

                  Co-Author ASP.NET AJAX in Action

                  S 1 Reply Last reply
                  0
                  • R Rama Krishna Vavilala

                    Shog9 wrote:

                    was this perhaps originally designed on a machine where those shades of grey matched?

                    No it was end-user designed screen (The app has an HTML form designer built into it which allows end users to design screens). He might be using a different theme in the application.

                    Co-Author ASP.NET AJAX in Action

                    S Offline
                    S Offline
                    Shog9 0
                    wrote on last edited by
                    #25

                    Rama Krishna Vavilala wrote:

                    (The app has an HTML form designer built into it which allows end users to design screens)

                    Slick. :cool:

                    every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                    1 Reply Last reply
                    0
                    • S Shog9 0

                      C# is the new VB. The so-called VB.NET is just for... you know, handicapped folk. People whose keyboards are missing semicolons and curly braces.

                      every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                      L Offline
                      L Offline
                      led mike
                      wrote on last edited by
                      #26

                      Shog9 wrote:

                      C# is the new VB.

                      So that means that C is the old VB right? Because I am currently working with some C source code that is as bad a piece of work as I have ever seen. Technically they ported it to C++ a few years back. Basically they changed the file names to .cpp and malloc/free to new/delete. *groan* It's so bad about the only advice I would give about improving the code is to never allow people like that to create any. Languages don't kill projects, people do. I hope you remember me enough to know this is NOT a defense of VB :laugh:

                      S 1 Reply Last reply
                      0
                      • R Rama Krishna Vavilala

                        Ok Let's play the game: VB or .NET or Win Forms or WTL or MFC? The UI is at the following location: Screenshot

                        Co-Author ASP.NET AJAX in Action

                        L Offline
                        L Offline
                        led mike
                        wrote on last edited by
                        #27

                        Rama Krishna Vavilala wrote:

                        Ok Let's play the game:

                        I'm in. The UI is built on 3rd party components rendering the application development platform irrelevant to this discussion.

                        R 1 Reply Last reply
                        0
                        • L led mike

                          Shog9 wrote:

                          C# is the new VB.

                          So that means that C is the old VB right? Because I am currently working with some C source code that is as bad a piece of work as I have ever seen. Technically they ported it to C++ a few years back. Basically they changed the file names to .cpp and malloc/free to new/delete. *groan* It's so bad about the only advice I would give about improving the code is to never allow people like that to create any. Languages don't kill projects, people do. I hope you remember me enough to know this is NOT a defense of VB :laugh:

                          S Offline
                          S Offline
                          Shog9 0
                          wrote on last edited by
                          #28

                          led mike wrote:

                          So that means that C is the old VB right?

                          Heh, well... i've seen some baaad C code, but it usually takes the form of excessively long functions, lots of global data, unsafe string/memory manipulation, and bizarre control flow. VB's "everything attached to a form or other bit of UI with arbitrary datatypes and type conversions, with a gratuitous 3rd-party control thrown in to do something simple like sort" isn't necessarily worse, just distinctive. Of course, we all know that bad code can be written in any language. But just as your country of origin largely determines whether you put ketchup or brown sauce on your hotdog or meat pie, the language you use does have an effect on which mistakes you're likely to make. ;)

                          every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                          L 1 Reply Last reply
                          0
                          • L led mike

                            Rama Krishna Vavilala wrote:

                            Ok Let's play the game:

                            I'm in. The UI is built on 3rd party components rendering the application development platform irrelevant to this discussion.

                            R Offline
                            R Offline
                            Rama Krishna Vavilala
                            wrote on last edited by
                            #29

                            There is only 1 third part component (CodeJock) rest of the stuff is built in house or uses standard controls.

                            Co-Author ASP.NET AJAX in Action

                            L 1 Reply Last reply
                            0
                            • R Rama Krishna Vavilala

                              There is only 1 third part component (CodeJock) rest of the stuff is built in house or uses standard controls.

                              Co-Author ASP.NET AJAX in Action

                              L Offline
                              L Offline
                              led mike
                              wrote on last edited by
                              #30

                              Rama Krishna Vavilala wrote:

                              only 1 third part

                              That's enough to qualify my statement.

                              R 1 Reply Last reply
                              0
                              • M Marc Clifton

                                Those are good seven steps for any language, not just VB! Though #1 (normalize the UI) is amusing because I can always tell a VB app because of the funky colors, large fonts, and odd UI. Marc

                                Thyme In The Country
                                Interacx
                                My Blog

                                B Offline
                                B Offline
                                Big Daddy Farang
                                wrote on last edited by
                                #31

                                Marc Clifton wrote:

                                I can always tell a VB app because of the...

                                I thought you were going to say "stench." BDF

                                1 Reply Last reply
                                0
                                • S Shog9 0

                                  led mike wrote:

                                  So that means that C is the old VB right?

                                  Heh, well... i've seen some baaad C code, but it usually takes the form of excessively long functions, lots of global data, unsafe string/memory manipulation, and bizarre control flow. VB's "everything attached to a form or other bit of UI with arbitrary datatypes and type conversions, with a gratuitous 3rd-party control thrown in to do something simple like sort" isn't necessarily worse, just distinctive. Of course, we all know that bad code can be written in any language. But just as your country of origin largely determines whether you put ketchup or brown sauce on your hotdog or meat pie, the language you use does have an effect on which mistakes you're likely to make. ;)

                                  every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                                  L Offline
                                  L Offline
                                  led mike
                                  wrote on last edited by
                                  #32

                                  Shog9 wrote:

                                  VB's "everything attached to a form

                                  Only because those guys that did...

                                  Shog9 wrote:

                                  excessively long functions, lots of global data, unsafe string/memory manipulation, and bizarre control flow.

                                  .... didn't have forms! :laugh::laugh::laugh: Your description is fairly close to what I am dealing with. They also abuse the heap and of course pointers. And the bizzarre control flow/state management results in thread affinity rendering the entire body of work useless in todays world.

                                  S 1 Reply Last reply
                                  0
                                  • L led mike

                                    Shog9 wrote:

                                    VB's "everything attached to a form

                                    Only because those guys that did...

                                    Shog9 wrote:

                                    excessively long functions, lots of global data, unsafe string/memory manipulation, and bizarre control flow.

                                    .... didn't have forms! :laugh::laugh::laugh: Your description is fairly close to what I am dealing with. They also abuse the heap and of course pointers. And the bizzarre control flow/state management results in thread affinity rendering the entire body of work useless in todays world.

                                    S Offline
                                    S Offline
                                    Shog9 0
                                    wrote on last edited by
                                    #33

                                    led mike wrote:

                                    Only because those guys that did... .... didn't have forms!

                                    Yup! ;) Just think what VB code would be like if pointer ops were more obvious in that language...(!)

                                    every night, i kneel at the foot of my bed and thank the Great Overseeing Politicians for protecting my freedoms by reducing their number, as if they were deer in a state park. -- Chris Losinger, Online Poker Players?

                                    1 Reply Last reply
                                    0
                                    • R Rama Krishna Vavilala

                                      Ok Let's play the game: VB or .NET or Win Forms or WTL or MFC? The UI is at the following location: Screenshot

                                      Co-Author ASP.NET AJAX in Action

                                      P Offline
                                      P Offline
                                      peterchen
                                      wrote on last edited by
                                      #34

                                      A VB scaffolding around WTL + MFC code?


                                      We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                                      My first real C# project | Linkify!|FoldWithUs! | sighist

                                      1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        Rama Krishna Vavilala wrote:

                                        The correct answer is All of The Above

                                        Nice! That must have been quite interesting to put all together. Marc

                                        Thyme In The Country
                                        Interacx
                                        My Blog

                                        R Offline
                                        R Offline
                                        Rama Krishna Vavilala
                                        wrote on last edited by
                                        #35

                                        Yes it was! It started as a VB6 Project. A genius programmer (not me;)) wrote the entire VB code. If someone wants to learn about "Program into your language not program in your language", his VB6 code is a great example. Later it fell in my hands to redesign the UI. I started with CodeJock MFC controls as it gave lot of rich features. However it was not wise to rewrite the entire VB code and port it over to C++. At that time .NET was already out and I was not impressed with Winforms so decided to have a wait and watch policy to see what happens in the UI world. So I decided to do re-use them in MFC as ActiveX controls. The policy was to write new things in C++. Some stuff needed to be modified in VB to change look and feel (as VB tabs did not look nice to sales people), so I developed the tab control in ATL/WTL as VB could host only activeX controls. That being done majority about 40% of the app code was in VB6 and 60% in MFC. The main reason to move to MFC was to allow the application to have some advanced capabilities like in-built HTML form designer which will allow end-users to design their own custom UIs easily which will work both on web and on the desktop. In 2 versions, VB6 was totally unsupported so the phase out VB6 code started. It was decided to use the .NET WInforms DataGridView to replace some of the grid functionality only in the most crucial screen which was a table editing screen. We started hosting .NET control as an ActiveX control it worked but later on figured out that it works well if there is a UserControl which hosts the DataGridViewControl (databinding did not work if the DatagridView was not hosted in a UserControl). We also ended up using C++/CLI to make everything work well in MFC application. Now C++/CLI stinks for any use apart from using it as a thunk layer. So majority of the code written to support the DataGridView (in virtual mode) was written in C#. Also not (shown in the screenshot) we had a property grid for HTML designer which also is the .NET property grid. To support the property grid there was lot of C# code written as property grid associates with .NET objects better. Anyway the lessons learned from this project will span multiple articles but probably it will not be useful to anyone. The main idea was always to bring something quick into production while keeping with technologies, rewriting code especially well tested code is not always the best way to do that. Now that WPF has come out the new direction of new UI development in the app is to be re-thought.

                                        M 1 Reply Last reply
                                        0
                                        • L led mike

                                          Rama Krishna Vavilala wrote:

                                          only 1 third part

                                          That's enough to qualify my statement.

                                          R Offline
                                          R Offline
                                          Rama Krishna Vavilala
                                          wrote on last edited by
                                          #36

                                          sort of!

                                          Co-Author ASP.NET AJAX in Action

                                          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