|
You could short it down to something like:
Private Sub SetUIActivated(ByBal Active As Boolean)
control1.Enabled = Active
control2.Enabled = Active
End Sub
|
|
|
|
|
ohh! Such a simple Solution and I never thought. I need to slap myself.
5 to you!
|
|
|
|
|
Haha and thanks.
But I still committed the crime too :S
|
|
|
|
|
Always think and revisit a piece of code which you just wrote, and you understand how best you can re-write it.
-- Rushi
|
|
|
|
|
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.
|
|
|
|
|
an elegant solution would be to put the controls in question into a dedicated collection and iterate over this
|
|
|
|
|
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
|
|
|
|
|
And even improve that (for readability) using...
Private Sub EnableControls()
SetUIActivated(True)
End Sub
Private Sub DisableControls()
SetUIActivated(False)
End Sub
|
|
|
|
|
It's never a good idea to provide multiple ways to do the same thing
|
|
|
|
|
i used to do that too
|
|
|
|
|
You used VB!
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)
|
|
|
|
|
saw this at work today....
if (Status == "something")
{
randomValue = true;
}
else
{
randomValue = true;
}
That was it. No other code in that if/else statement.
|
|
|
|
|
there is no doubt that randomValue is definitively true.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
There is undoubtedly another DLL that inspects this DLL's IL to ensure the code has not been tampered with. If it finds that somebody removed the seemingly extraneous if statement, it will cause ThreadAbortExceptions at random intervals.
|
|
|
|
|
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
|
|
|
|
|
I am going to guess that one of those blocks should be setting randomValue = false.
If so I would prefer this much simplier version:
randomValue = status == "something";
However, when I see code like that I have to check everything around it for correct logic.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Setting a random value to true... that is very random.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
I'll guess that this code has been significantly reorganized and these are the only statements left from a major cutback.
Otherwise, we must assume that the author is insane.
|
|
|
|
|
there is an obvious flaw in this code, it should read like:
if (Status == "something")
{
randomValue = true;
}
else if (Status != "something")
{
randomValue = true;
}
else
{
randomValue = true;
}
|
|
|
|
|
System.Windows.Forms.MessageBox.Show
When used on "Web Application" actualy works on Visual Studio 2010 during debug runtime not a single warning or error.
Just to find out that once compiled and uploaded to be viewed online then you get ERROR saying it was only meant for local application. Then why the hell they don't even tell while you where debuging it took me about 4 hours to found this out.
you will get this error:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Beware of this .Net debuging st*p*d*ty! or maybe I was the problem
I was st*p*d to believe in some guy posting that this is better way to show message box on Web App.
|
|
|
|
|
You aren't the first to do that, and you won't be the last. I deal with maybe one Q&A question aasking "why doesn't this work anymore?" each week...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Developers often forget that to show a message box on the client computer, the code must be running on the client computer, but in case of a web app, the code runs on the web server. Use JavaScript's alert() to show message box in the browser.
|
|
|
|
|
Even worse are the possibilities that if this code did actually work, you now have a modal dialaog box open on the server waiting for user input. How many of those do you think can be spawned before some kind of memory error occurs?
-- modified 17-Jan-19 21:01pm.
|
|
|
|
|
I've come to a conclusion that the way that software get maintained, backed-up, ect. is a big problem area in computers today.
How many hours do I sometimes spend searching/downloading the correct revisions of software programs/libraries/functions. Lots of times the backed up files is found all over the place(Download something on this site, then that site and so on). We need a "mother system".
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|