|
What data are we tracking here with 50 double textboxes on a single screen?
Oops. 4.75255314 should have been in textbox 35 not 37..
|
|
|
|
|
That's what's even worse than the code and the design: it's an invoicing system, and these are for the prices he's going to invoice to the customer ... hence the total
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I think the OP is working at my place nowadays[^].
Be excellent to each other. And... PARTY ON, DUDES!
Abraham Lincoln
|
|
|
|
|
What's wrong with that code?
|
|
|
|
|
Remind me never to employ you!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
I will just use that code as my resume and the reminding shall occur.
|
|
|
|
|
Absolutely no comments.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Isn't this the original Excel source code?
|
|
|
|
|
I don think so. If it was, it would more likely be
ptotal = Double.Parse(Me.txttA.Text) + Double.Parse(Me.txttB.Text) + Double.Parse(Me.txttC.Text) + _
Double.Parse(Me.txttD.Text) + Double.Parse(Me.txttE.Text) + Double.Parse(Me.txttF.Text) + _
Double.Parse(Me.txttG.Text) + Double.Parse(Me.txttH.Text) + Double.Parse(Me.txttI.Text) + _
Double.Parse(Me.txttA0.Text) + Double.Parse(Me.txttAA.Text) + Double.Parse(Me.txttAB.Text) + _
Double.Parse(Me.txttAC.Text) + Double.Parse(Me.txttAD.Text) + Double.Parse(Me.txttAE.Text) + _
Double.Parse(Me.txttAF.Text) + Double.Parse(Me.txttAG.Text) + Double.Parse(Me.txttAH.Text) + _
Double.Parse(Me.txttAI.Text) + Double.Parse(Me.txttB0.Text) + Double.Parse(Me.txttBA.Text) + _
Double.Parse(Me.txttBB.Text) + Double.Parse(Me.txttBC.Text) + Double.Parse(Me.txttBD.Text) + _
Double.Parse(Me.txttBE.Text) + Double.Parse(Me.txttBF.Text) + Double.Parse(Me.txttBG.Text) + _
Double.Parse(Me.txttBH.Text) + Double.Parse(Me.txttBI.Text) + Double.Parse(Me.txttC0.Text) + _
Double.Parse(Me.txttCA.Text) + Double.Parse(Me.txttCB.Text) + Double.Parse(Me.txttCC.Text) + _
Double.Parse(Me.txttCD.Text) + Double.Parse(Me.txttCE.Text) + Double.Parse(Me.txttCF.Text) + _
Double.Parse(Me.txttCG.Text) + Double.Parse(Me.txttCH.Text) + Double.Parse(Me.txttCI.Text) + _
Double.Parse(Me.txttD0.Text) + Double.Parse(Me.txttDA.Text) + Double.Parse(Me.txttDB.Text) + _
Double.Parse(Me.txttDC.Text) + Double.Parse(Me.txttDD.Text) + Double.Parse(Me.txttDE.Text) + _
Double.Parse(Me.txttDF.Text) + Double.Parse(Me.txttDG.Text) + Double.Parse(Me.txttDH.Text) + _
Double.Parse(Me.txttDI.Text) + Double.Parse(Me.txttE0.Text)
Greetings - Jacek
|
|
|
|
|
What else can you do? Well lets seeeeee......
double ptotal = 0;
foreach(Control ctrl in this.controls)
{
if(ctrl is TextBox)
ptotal += Double.Parse(ctrl.Text);
}
|
|
|
|
|
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it.
This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = "<select statement>"
ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()
Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
|
|
|
|
|
Kill it! Kill it with fire!
|
|
|
|
|
It could be worse. The developer could have started an instance of one of the Microsoft Office applications to do the job (in a service).
Software Zen: delete this;
|
|
|
|
|
Yep. And for extra credit he could have used ActiveX to start it on the client!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Why you had to bring ActiveX into this ?
|
|
|
|
|
Because I am the AntiChrist, and it's my job to introduce Evil to the world?
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
You're creeping me out. That is exactly what he did with the DataSet!
|
|
|
|
|
"Your mission, should you choose to accept it, is to eradicate this evil from the world. As always, the Secretary will disavow any knowledge of your actions. This post will self-destruct in five seconds. Good luck, Gordon."
Software Zen: delete this;
|
|
|
|
|
Naw - then the other developers on the team complain because that's the way they have always done it. The senior developer on the team before you doesn't want to take the time and effort to teach more junior developers better ways of doing things. So in the end - you will rip out all the code you wrote, to replace it with 5X more code/execution paths to be tested
Phil
|
|
|
|
|
I'll assemble my elite team now! Thanks
|
|
|
|
|
I've seen people try that - it normally fails, horribly.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Ignoring the legal implications (server usage of Microsoft Office apps violates the license), the Office apps fail in odd ways or cause unusual server failures when used in this fashion.
Software Zen: delete this;
|
|
|
|
|
I'm just a trainee and I still have a LOT to learn (and wrote some sh*tty code myself), but even to me this looks... funny
|
|
|
|
|
Look at it hard. Study it. Do the opposite and you'll do well in your career. Best to you.
|
|
|
|
|
Thanks! Learning what not to do is also important, that's why I always take a look around here
|
|
|
|