Please laugh at me so I never do this again...
-
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
-
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
-
I also do such stuff. What's wrong with it. I need a slap if there is something wrong with it. :^)
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 -
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 -
Haha and thanks. But I still committed the crime too :S
-
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
-
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 SubNow 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."
-
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
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)
-
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."
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.
-
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 SubNormally in such a situation I also try to put the affected controls into one Panel or GroupBox and just enable/disable that one. Robert
-
Always think and revisit a piece of code which you just wrote, and you understand how best you can re-write it. -- Rushi
-
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 SubAnd even improve that (for readability) using...
Private Sub EnableControls()
SetUIActivated(True)
End Sub
Private Sub DisableControls()
SetUIActivated(False)
End Sub -
And even improve that (for readability) using...
Private Sub EnableControls()
SetUIActivated(True)
End Sub
Private Sub DisableControls()
SetUIActivated(False)
End SubIt's never a good idea to provide multiple ways to do the same thing
-
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.
an elegant solution would be to put the controls in question into a dedicated collection and iterate over this