• Welcome to Valhalla Legends Archive.
 

Better way to do this?

Started by Barabajagal, September 08, 2007, 02:24 PM

Previous topic - Next topic

FrOzeN

Horrible code. Just one thing I'll bother pointing out, the only thing that you are actually forcing a data type conversion (CBool()ing the whole equation) is already a boolean. You'd be better of forcing CInt() on your 1st and 3rd call to ReadINI().

Also, @Banana fanna fo fanna: When running code over numerous lines in VB6 you need to add " _" to the end of each line.
~ FrOzeN

brew

Quote from: Andy on September 11, 2007, 02:43 PM
"Antiquis temporibus, nati tibi similes in rupibus ventosissimis exponebantur ad necem"

YAY

"In the times of old, the children like you were left to perish on the windiest crags."
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

I'm not posting any more in this (or any topic) unless it's relevant to the topic's original post.

Falcon[anti-yL]

Quote from: Andy on September 11, 2007, 04:55 PM
I'm not posting any more in this (or any topic) unless it's relevant to the topic's original post.
And people would care why?

Joe[x86]

Quote from: brew on September 11, 2007, 02:23 PM
That code wouldn't work. You're forgetting a ) on the first line. Not only that, but also why would you be CBool()ing a value that's already a boolean...? And I'm not even mentioning half the other bad coding habits in that sample. I sware to god. If there were no such things as code optimizers we would all be dead because of crappy code. Back in the 70-80s if you wrote it like that you would have been shot.

I'm rolling on the floor laughing. Did you just tell Camel he has bad coding habits?!
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

brew

#35
Quote from: Joex86] link=topic=17010.msg172668#msg172668 date=1189584917]
Quote from: brew on September 11, 2007, 02:23 PM
That code wouldn't work. You're forgetting a ) on the first line. Not only that, but also why would you be CBool()ing a value that's already a boolean...? And I'm not even mentioning half the other bad coding habits in that sample. I sware to god. If there were no such things as code optimizers we would all be dead because of crappy code. Back in the 70-80s if you wrote it like that you would have been shot.

I'm rolling on the floor laughing. Did you just tell Camel he has bad coding habits?!
...I guess. Realityripple too.


CheckIdleUser = CBool(ReadINI("Main", "UserIdleTime", "20", strConfig) > 0
     And ReadINI("Main", "UserIdleGray", "Y", strConfig) = "Y"
     And GetTickCount \ 1000 - lvChannel.ListItems(UserIndex).SubItems(4) > ReadINI("Main", "UserIdleTime", "20", strConfig) * 60
     And lvChannel.ListItems(UserIndex).ForeColor <> OtherApp.Error)

i would rewrite like so

Public Function CheckIdleUser(blahblah) As Boolean
   If CLng(ReadINI("Main", "UserIdleTime", "20", strConfig)) Then 'wtf? the user is really going to have a negative idle time, huh. especially when your configuration dialog box is supposed to handle that. You should compare that value to 0. Actually, why not use the windows registry for something like this? It's made for this kind of thing. Even better, prefetch those values to global variables on startup.
      If ReadINI("Main", "UserIdleGray", "Y", strConfig) = "Y" Then
         If GetTickCount \ 1000 - lvChannel.ListItems(UserIndex).SubItems(4) > CLng(ReadINI("Main", "UserIdleTime", "20", strConfig)) * 60 Then
            If lvChannel.ListItems(UserIndex).ForeColor <> OtherApp.Error) Then CheckIdleUser = True
         End If
      End If
End If
End Function


Efficiency is the key to productivity, and productivity is the key to success.
VB6 code, although very inefficient itself, should be optimized. Stop forcing your optimizer to do extra work for the sake of code readabilty. Keep it up, and the next generation of programmers might be that much more stupid.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

FrOzeN

#36
brew, shut up. Camel was posting code for readability, not minor changes to efficiency. Being that you are so genius at VB6, why didn't you pick up the slow string comparison?

If ReadINI("Main", "UserIdleGray", "Y", strConfig) = "Y" Then
Should be:
If AscW(ReadINI("Main", "UserIdleGray", "Y", strConfig) = 89 Then

EDIT - To be fair, I reread your post brew, and have to give you some credit for what you said. Based on the skill level I've seen you at, no comment, it's actually nice to see people such as you learning to optimize their code.
~ FrOzeN

brew

Quote from: FrOzeN on September 13, 2007, 07:28 AM
brew, shut up. Camel was posting code for readability, not minor changes to efficiency. Being that you are so genius at VB6, why didn't you pick up the slow string comparison?

If ReadINI("Main", "UserIdleGray", "Y", strConfig) = "Y" Then
Should be:
If AscW(ReadINI("Main", "UserIdleGray", "Y", strConfig) = 89 Then

EDIT - To be fair, I reread your post brew, and have to give you some credit for what you said. Based on the skill level I've seen you at, no comment, it's actually nice to see people such as you learning to optimize their code.

Oh wow, I really didn't think about using Asc(). I'm not a genius at vb6, I'm just not stupid. The language itself is stupid. People who make stupid mistakes with such a stupid language really need to get smart.
And what is the skill level I'm at ? (well, what you say i am at, actually) Please, do tell.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

MysT_DooM



vb6, something about that combination of numbers and letters is sexy

FrOzeN

Quote from: brew on September 12, 2007, 05:48 PMEfficiency is the key to productivity, and productivity is the key to success.
VB6 code, although very inefficient itself, should be optimized. Stop forcing your optimizer to do extra work for the sake of code readabilty. Keep it up, and the next generation of programmers might be that much more stupid.
Quote from: brew on September 13, 2007, 02:12 PMOh wow, I really didn't think about using Asc(). I'm not a genius at vb6, I'm just not stupid. The language itself is stupid. People who make stupid mistakes with such a stupid language really need to get smart.
First you said Camel has bad coding habits, and then all you really change from his code is a breaking it up into a few If statements and then through in some CLng()'s and talk about how efficient your code is. So I pointed out a simple flaw that any good coder who is optimizing code should pick up. Secondly, a string comparison isn't just a VB6 related thing, anyone should know comparing numbers is always faster than comparing strings regardless of the language (may* be some exceptions depending on how a string is defined in that language).

Quote from: brew on September 13, 2007, 02:12 PMAnd what is the skill level I'm at ? (well, what you say i am at, actually) Please, do tell.
No comment was my comment, it was a sarcastic way of saying "shit".

Oh finally, if you carefully reread your sentence, you just told yourself to get smart.
"People who make stupid mistakes (like you did) with such a stupid language (what you called it) really need to get smart."
~ FrOzeN

brew

#40
Quote
First you said Camel has bad coding habits, and then all you really change from his code is a breaking it up into a few If statements and then through in some CLng()'s and talk about how efficient your code is. So I pointed out a simple flaw that any good coder who is optimizing code should pick up. Secondly, a string comparison isn't just a VB6 related thing, anyone should know comparing numbers is always faster than comparing strings regardless of the language (may* be some exceptions depending on how a string is defined in that language).
No comment was my comment, it was a sarcastic way of saying "shit".

Oh finally, if you carefully reread your sentence, you just told yourself to get smart.
"People who make stupid mistakes (like you did) with such a stupid language (what you called it) really need to get smart."

My version of the code is much different if you look closer, I wouldn't be surpised if it shaves an entire millisecond off of the execution time. Yeah, I know that a string comparison is slower. thanks. I just didn't SEE that or even think about that, one simple mistake. I was talking about the people who don't make an effort to make a program actually nice, so on.
By the way, I have reviewed your posts. From what I've seen, it appears that I'm actually on a much higher skill level then you. The first post you talk about code in was showing someone how to use an "If" statement. The last post where you actually spoke of code was a visual basic 6 implementation of creating a rich edit box. In C++, too. Come on, I've done that about a year ago. And I didn't have any problems with it either. It's very easy, actually. Throughout your posts, you just talk about visual basic, visual basic, blah blah, and nothing ever about C or a better language ? Oh sorry, PHP too. a web *scripting* language. Not to bash PHP or anything, but the average PHP developer has the IQ of a stone. And they generally don't have any idea of what they're doing. So please, if you want to flame me, put in more effort at least. And consider your own skill level before posting about someone else's skill level.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

NONE OF THIS IS IMPORTANT. I WANT TO KNOW IF THERE'S A BETTER WAY THAN USING A SECOND RICH TEXT BOX, NOT HOW TO NITPICK VB CODE. ARGH~!

Spht

Quote from: Andy on September 14, 2007, 02:36 PM
NONE OF THIS IS IMPORTANT. I WANT TO KNOW IF THERE'S A BETTER WAY THAN USING A SECOND RICH TEXT BOX, NOT HOW TO NITPICK VB CODE. ARGH~!

Yes, of course there are.  there are much better ways.  now, back to the nitpicking vb code

Barabajagal

Fuck it. I give up on asking here for help.

FrOzeN

Quote from: brew on September 14, 2007, 02:31 PMFrom what I've seen, it appears that I'm actually on a much higher skill level then you.
Granted. From what you've seen of me I say your assumption is feasible. That however, does not make it correct. Being that I can't really back any statement of me being a more skillful than you as a programmer without going out of my way, I'll leave you to believe what you like. Though, being that you say you could create things like RichEdit boxes in C++ about a year ago, I find it funny how you still don't know how to use debugging tools in C++. :-\
~ FrOzeN

|