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. Other Discussions
  3. The Weird and The Wonderful
  4. Please laugh at me so I never do this again...

Please laugh at me so I never do this again...

Scheduled Pinned Locked Moved The Weird and The Wonderful
14 Posts 9 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.
  • H Offline
    H Offline
    henrikqwerty321
    wrote on last edited by
    #1

    This is actually an epic fail I did myself, just yesterday... I believe I should be punished for this horrible act against humanity so please laugh at me so I never do it again...

    Private Sub enableControls()
            txtDbHost.Enabled = True
            txtDbName.Enabled = True
            txtDbPass.Enabled = True
            //Continues all the way down....
    End Sub
    Private Sub disableControls()
            txtDbHost.Enabled = False
            txtDbName.Enabled = False
            txtDbPass.Enabled = False
           //Continues all the way down....
    End Sub
    

    Worst thing is that it is part of a project I send into Codecanyon, I really think it's going to get rejected for that blunder.

    Henrik Pedersen - HSP Software - www.hsp.dk

    L 8 N 3 Replies Last reply
    0
    • H henrikqwerty321

      This is actually an epic fail I did myself, just yesterday... I believe I should be punished for this horrible act against humanity so please laugh at me so I never do it again...

      Private Sub enableControls()
              txtDbHost.Enabled = True
              txtDbName.Enabled = True
              txtDbPass.Enabled = True
              //Continues all the way down....
      End Sub
      Private Sub disableControls()
              txtDbHost.Enabled = False
              txtDbName.Enabled = False
              txtDbPass.Enabled = False
             //Continues all the way down....
      End Sub
      

      Worst thing is that it is part of a project I send into Codecanyon, I really think it's going to get rejected for that blunder.

      Henrik Pedersen - HSP Software - www.hsp.dk

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

      I also do such stuff. What's wrong with it. I need a slap if there is something wrong with it. :^)

      H 1 Reply Last reply
      0
      • L Lost User

        I also do such stuff. What's wrong with it. I need a slap if there is something wrong with it. :^)

        H Offline
        H Offline
        henrikqwerty321
        wrote on last edited by
        #3

        You could short it down to something like:

        Private Sub SetUIActivated(ByBal Active As Boolean)
        control1.Enabled = Active
        control2.Enabled = Active
        //Continues like hell...
        End Sub

        L R R R 4 Replies Last reply
        0
        • H henrikqwerty321

          You could short it down to something like:

          Private Sub SetUIActivated(ByBal Active As Boolean)
          control1.Enabled = Active
          control2.Enabled = Active
          //Continues like hell...
          End Sub

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

          ohh! Such a simple Solution and I never thought. I need to slap myself. :zzz: 5 to you!

          H J 2 Replies Last reply
          0
          • L Lost User

            ohh! Such a simple Solution and I never thought. I need to slap myself. :zzz: 5 to you!

            H Offline
            H Offline
            henrikqwerty321
            wrote on last edited by
            #5

            Haha and thanks. But I still committed the crime too :S

            1 Reply Last reply
            0
            • H henrikqwerty321

              This is actually an epic fail I did myself, just yesterday... I believe I should be punished for this horrible act against humanity so please laugh at me so I never do it again...

              Private Sub enableControls()
                      txtDbHost.Enabled = True
                      txtDbName.Enabled = True
                      txtDbPass.Enabled = True
                      //Continues all the way down....
              End Sub
              Private Sub disableControls()
                      txtDbHost.Enabled = False
                      txtDbName.Enabled = False
                      txtDbPass.Enabled = False
                     //Continues all the way down....
              End Sub
              

              Worst thing is that it is part of a project I send into Codecanyon, I really think it's going to get rejected for that blunder.

              Henrik Pedersen - HSP Software - www.hsp.dk

              8 Offline
              8 Offline
              88Rocker
              wrote on last edited by
              #6

              i used to do that too :)

              1 Reply Last reply
              0
              • H henrikqwerty321

                You could short it down to something like:

                Private Sub SetUIActivated(ByBal Active As Boolean)
                control1.Enabled = Active
                control2.Enabled = Active
                //Continues like hell...
                End Sub

                R Offline
                R Offline
                RobCroll
                wrote on last edited by
                #7

                Now that is a fail. Shouldn't the routine be called at worst SetUIEnabled or even better EnableControls. The code block doesn't activate anything. Maybe a more elegant solution would be to iterate through the forms controls and ignore the few controls you wish to remain enabled.

                Public Sub EnableControls(ByVal Enabled As Boolean)
                    For Each FormControl As Control In Me.Controls
                        FormControl.Enabled = Enabled
                    Next
                End Sub
                

                Personally I didn't see anything wrong with your original solution except that the routine names were lower case.

                "You get that on the big jobs."

                H 1 Reply Last reply
                0
                • H henrikqwerty321

                  This is actually an epic fail I did myself, just yesterday... I believe I should be punished for this horrible act against humanity so please laugh at me so I never do it again...

                  Private Sub enableControls()
                          txtDbHost.Enabled = True
                          txtDbName.Enabled = True
                          txtDbPass.Enabled = True
                          //Continues all the way down....
                  End Sub
                  Private Sub disableControls()
                          txtDbHost.Enabled = False
                          txtDbName.Enabled = False
                          txtDbPass.Enabled = False
                         //Continues all the way down....
                  End Sub
                  

                  Worst thing is that it is part of a project I send into Codecanyon, I really think it's going to get rejected for that blunder.

                  Henrik Pedersen - HSP Software - www.hsp.dk

                  N Offline
                  N Offline
                  Nagy Vilmos
                  wrote on last edited by
                  #8

                  You used VB! :-D


                  Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre Have a bit more patience with newbies. Of course some of them act dumb -- they're often *students*, for heaven's sake. -- (Terry Pratchett, alt.fan.pratchett)

                  1 Reply Last reply
                  0
                  • R RobCroll

                    Now that is a fail. Shouldn't the routine be called at worst SetUIEnabled or even better EnableControls. The code block doesn't activate anything. Maybe a more elegant solution would be to iterate through the forms controls and ignore the few controls you wish to remain enabled.

                    Public Sub EnableControls(ByVal Enabled As Boolean)
                        For Each FormControl As Control In Me.Controls
                            FormControl.Enabled = Enabled
                        Next
                    End Sub
                    

                    Personally I didn't see anything wrong with your original solution except that the routine names were lower case.

                    "You get that on the big jobs."

                    H Offline
                    H Offline
                    henrikqwerty321
                    wrote on last edited by
                    #9

                    Yeah sorry still trying to get the naming conventions -.-' (PHP and C++ is messing around with my head)... But about the part of looping trough the form I don't think it's the right solution as the majority of controls must remain unchanged.

                    T 1 Reply Last reply
                    0
                    • H henrikqwerty321

                      You could short it down to something like:

                      Private Sub SetUIActivated(ByBal Active As Boolean)
                      control1.Enabled = Active
                      control2.Enabled = Active
                      //Continues like hell...
                      End Sub

                      R Offline
                      R Offline
                      Robert Rohde
                      wrote on last edited by
                      #10

                      Normally in such a situation I also try to put the affected controls into one Panel or GroupBox and just enable/disable that one. Robert

                      1 Reply Last reply
                      0
                      • L Lost User

                        ohh! Such a simple Solution and I never thought. I need to slap myself. :zzz: 5 to you!

                        J Offline
                        J Offline
                        Joshi Rushikesh
                        wrote on last edited by
                        #11

                        Always think and revisit a piece of code which you just wrote, and you understand how best you can re-write it. -- Rushi

                        1 Reply Last reply
                        0
                        • H henrikqwerty321

                          You could short it down to something like:

                          Private Sub SetUIActivated(ByBal Active As Boolean)
                          control1.Enabled = Active
                          control2.Enabled = Active
                          //Continues like hell...
                          End Sub

                          R Offline
                          R Offline
                          Rob Grainger
                          wrote on last edited by
                          #12

                          And even improve that (for readability) using...

                          Private Sub EnableControls()
                          SetUIActivated(True)
                          End Sub
                          Private Sub DisableControls()
                          SetUIActivated(False)
                          End Sub

                          T 1 Reply Last reply
                          0
                          • R Rob Grainger

                            And even improve that (for readability) using...

                            Private Sub EnableControls()
                            SetUIActivated(True)
                            End Sub
                            Private Sub DisableControls()
                            SetUIActivated(False)
                            End Sub

                            T Offline
                            T Offline
                            TorstenFrings
                            wrote on last edited by
                            #13

                            It's never a good idea to provide multiple ways to do the same thing

                            1 Reply Last reply
                            0
                            • H henrikqwerty321

                              Yeah sorry still trying to get the naming conventions -.-' (PHP and C++ is messing around with my head)... But about the part of looping trough the form I don't think it's the right solution as the majority of controls must remain unchanged.

                              T Offline
                              T Offline
                              TorstenFrings
                              wrote on last edited by
                              #14

                              an elegant solution would be to put the controls in question into a dedicated collection and iterate over this

                              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