Integer to 8 checkboxes checked

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

46 Replies - 11656 Views - Last Post: 22 June 2012 - 04:22 PM Rate Topic: -----

#31 BobRodes   User is offline

  • Product Manager
  • member icon

Reputation: 606
  • View blog
  • Posts: 3,086
  • Joined: 19-May 09

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 07:51 AM

View PostKKUSA, on 18 June 2012 - 08:31 PM, said:

View PosttlhIn`toq, on 18 June 2012 - 06:11 PM, said:

The way you are going about this is far more work than needed.


Yes, I know, but Im not a professional programmer nor used to this type of programming, so I have to do it how I can even if its not the "best" way, as long as it works properly.

You were doing very well with tlhin's advice until this post.

A great improvement on your response would be "so how could I simplify this?" Might not be as difficult as you think. Also, if you are trying to teach yourself something here (which clearly you are, because you have more "bells and whistles" on this thing than you require), then you might want to learn how to do something in 10 lines of code instead of 100, which very often is the sort of economy you can realize as soon as you take yourself out of the "I just want it to work" mindset. Replacing that mindset with "I want it to work in the simplest way possible" will save you, a non-professional, every bit as many headaches as a professional. Just less often, since you're not doing this all the time.

tlhin's putting a good deal of effort into helping you, because you've shown that you want to learn something. Suppose you reward his efforts by going the extra mile. You'll be glad you did, because you obviously have the talent to understand and apply what he's telling you.

Consider yourself scolded for a stupidass response. :)

By the way, the VB.Net equivalent of C# "!" in this case is simply "Not". @thlin: VB.Net "Not" is overloaded to represent both negation and bitwise complement, and there is also an "IsNot" to negate reference equality.

This post has been edited by BobRodes: 19 June 2012 - 07:57 AM

Was This Post Helpful? 2
  • +
  • -

#32 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 08:37 AM

If there is something about the logic of the program I gave you that you don't follow let me know. As a rule, logic comes before code. If you can find/create/understand the logic you want to follow the code comes easy. If you start by banging out lots of lines of code, then try to make the logic follow the code it get ugly quickly.
Was This Post Helpful? 0
  • +
  • -

#33 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 09:05 AM

The logic explained.

Most of this is centered around the method "Recalculate".
That method looks at the checkboxes and calculates a new value for the string property "Binary" and sets the value for the numericUpDown so it stays in sync with the value.

When "Binary" is set, it updates the label for the user, and ticks/unticks the checkboxes as needed.

When the numericUpDown value is changed, Recalculate() is called again.

So...
Checkboxes cause Recalculate()
Recalculate() updates Binary and NumericUpDown
Binary and NumericUpDown cause Recalculate()

Its a circular pattern that ends when everything is updated because no more .Changed events are thrown by any control.

Attached Image

And all the while we don't micromanage the state of the checkboxes or any other control. We trust in our understanding that they will be correctly set when an event is raised.

This post has been edited by tlhIn`toq: 19 June 2012 - 09:07 AM

Was This Post Helpful? 2
  • +
  • -

#34 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 04:21 PM

I do understand what you are doing there, and I am basically doing the same thing, I think. However, I do not see how it will handle the conditionals of ANOTHER set of checkboxes.

Say I use your example exactly, duplicate it for a second set of check boxes, how would I make sure only one of Checkbox1 is checked?

Like this pseudo code:

If Checkbox1 in set1 is checked THEN Checkbox1 in set2 is unchecked
If Checkbox1 in set2 is checked THEN Checkbox1 in set1 is unchecked


That is the logic I'm after, however I have tried many different implementations of this logic on checkboxes and they simply do not function the way you would expect. Many of the examples I have found online work the same way, and do not ensure that only one of the two checkboxes are checked. It appears to be an issue many have come across.


An example of how I would expect them to work is in the application I attached previously. Thats the only working example I can think to show you.
Was This Post Helpful? 0
  • +
  • -

#35 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 05:16 PM

All of this code would go into the UserControl we discussed: NOT in the main application.

The UserControl handles all the checkboxes and labels etc.

Then you just place 2-2000 instances of the UserControl on your form.

For the logic you are talking about you would simply subtract a value from one of the UserControls.

If ControlOne and ControlTwo both have checkbox1 set to true, then subtract 1 from one of the values and it will go off.

if it is checkbox 2 in question then subtract 4 from from the value.

In other words, don't micromanage the checkboxes, just adjust the value of one of the UserControls and it will take care of its own checkboxes.

This post has been edited by tlhIn`toq: 19 June 2012 - 05:18 PM

Was This Post Helpful? 0
  • +
  • -

#36 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 19 June 2012 - 06:30 PM

I was actually doing it that way, by adding or subtracting from the value, but in the main code. Thats where everything is right now. It just will not uncheck boxes properly, even though the value created is correct.

I had a go a creating a user control but I could not figure it out. I followed some tut's I found, but did not succeed.

I will try again, I guess I'm just missing something.
Was This Post Helpful? 0
  • +
  • -

#37 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 07:19 AM

Maybe I can help if I understood the end goal.
This started as one thing... but now is becoming something more.
So what is it you are trying to build?
Was This Post Helpful? 0
  • +
  • -

#38 BobRodes   User is offline

  • Product Manager
  • member icon

Reputation: 606
  • View blog
  • Posts: 3,086
  • Joined: 19-May 09

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 01:51 PM

The dreaded "scope creep" rears its ugly head...
Was This Post Helpful? 1
  • +
  • -

#39 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 02:50 PM

Look at the example I attached. The checkbox array in the "custom area" at the upper right. That's what I'm trying to do. I have all of it working properly except for the conditionals.

With all due respect, I think I was going about asking for help in a manner that seems acceptable,....incrementally. If I were to say off the bat "Tell me how to do this, tell me how to do that, and this, and that", I would not have gotten any help. I'm sorry for trying to go about it in a manner that doesn't say "gimme, gimme, gimme"!!!

I also think there may be some confusion on your end as to what im after due to the unfamiliarity of the way it needs to communicate with the hardware.


However, I will not return for any further help. I have taken what I can from your suggestions and I will try to make the best of it on my own. As quite frankly I thought this forum was different than most others. I may sound like a winy a$$, however I'm quite sick of the condescending, adolescent attitudes of the "BOBS" of the internet. They help NOTHING and NOBODY!!! This thread will just continue to be filled with trash like that, and be of no help to anyone if we keep going.

I apologize for pressing anybody to take the time to click on my thread, read what I have posted, try to understand my "scope" in my words, hitting the reply button and taking the time to type numerous replies. I dont think I held a gun to anybodys head. Not a single soul was obligated to do so. If people didnt want to be subjected to the "dreaded scope creep", they could have avoided it by simply not replying.


tlhIn, Your help is VERY MUCH appreciated, THANK YOU VERY MUCH!! You have helped tremendously...seriously..and you deserve a beer or two!!! If I cant figure it out, I will try to get help for the remainder of what I need elsewhere. Maybe I can get to a conclusion in few posts before a troll steps in.


Bob, that scolding really hurt!!! I can still feel it from yesterday......man did that hurt...you should see the lashings on my back! I think I'm going to need medical attention!! I thought "programmers" are supposed to have an intellect that typically doesn't stoop to such moronic, adolescent behavior. You must spend way too much time in the three and under section of the internet!!! Let me guess, it makes you feel young again? ....It shows!!!


Thanks again tlhIn !!!!

This post has been edited by KKUSA: 20 June 2012 - 02:51 PM

Was This Post Helpful? -4
  • +
  • -

#40 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 03:06 PM

You're right... You do sound like a spoiled child.

I can't frakin' believe that you would display such an adolescent outburst like that after all the help you've received in this thread.

I'll tell you right now to leave programming and take up baking, if you are going to throw a childish temper tantrum like that every time someone make a comment that isn't blowing sunshine and rainbows up your skirt. Skill can be learned. But attitude is something you CHOOSE. And you've chosen poorly. You obviously don't have the life skills to be able to get along in an industry that doesn't exist to give you constant praise for every little thing.

Quote

However, I will not return for any further help.

Good. Because right now I feel like a complete idiot for going against my better judgement for helping yet another rookie. I'd have to say you fall right into the category that caused these two blog entries of mine:
Quitting because of the unappreciative rookies
Rookies make it it hard to want to help rookies

Quote

I have taken what I can

I think that about sums up your intent here: Take what you can

I'll be adding your handle to my personal "DO NOT HELP" list.

Quote

I will try to get help for the remainder of what I need elsewhere.


Good. Don't let the door hit you on the arse on the way out.
Was This Post Helpful? 1
  • +
  • -

#41 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 05:10 PM

That post wasn't intended for you and your help IS much appreciated. I guess you didn't read into it enough!!

If the help I receive is in a condescending tone, I don't want it. I don't want help from someone who really doesn't want to help. That would be taking advantage, and that's not what I'm doing.

I didnt mean "I TOOK" as you presume. I meant, "what Ive learned", and if you really think that what someone has learned by your help is considered "taking" as you presume, then maybe you should quit!! If you have a problem with doing it, dont do it. That was kind of my point in the post above.

I don't know how to be more appreciative than to say thanks, and take what I've learned from you and put it to good use. I don't have anything to give back other than that as you are clearly a better programmer than I.

What more do you really expect from rookies? They don't have anything to offer you other than a thanks, and a rep point here and there. (which I gave) Its you that wants the praise! I mean that is all your doing if for...right? (which is appreciated)

Sorry, this is sort of like having a flat tire, somebody stopping to help you fix it on their own accord, and bitching about having to do it on the ride home!! I don't want that kind of help, and that's exactly where this was headed so I thought I would state my thoughts on the matter.


Oh well!!!! Better Days, and thanks again for what you have taught me!!

This post has been edited by KKUSA: 20 June 2012 - 05:24 PM

Was This Post Helpful? 0
  • +
  • -

#42 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 05:40 PM

I don't want praise. I couldn't care less about it.
You see I recognize that it comes from someone that is nothing but an anonymous identity half a world away... Nothing more than a harmless collection of photons on my monitor... They have no affect on my day, my pay, my way of life, whether or not I'll play catch with the dog or whether or not I'll get laid tonight.

For that same rationale, you should realize that critiquing you has exactly the same amount of affect on your life: NONE. Or at least only as much as you CHOOSE it does.

I know your childish comments were meant for BobRodes. But you see, he's a nice guy that helps a LOT of people. So nice in fact that he just ignored the comment and unsubscribed from the thread without telling you to "Go frak yourself". He was helping you. He didn't stroke your obviously fragile ego. That's not his job. You have friends and family to bolster your ego by telling you that you can do anything. The experts here care about actually seeing you learn and progress. And like most young people today you don't seem to realize that being talked to honestly and frankly is often the best help a man can give you.

He didn't tell you that you should quit coding... He didn't tell you that you are a moron... he didn't discuss your lineage in derogatory terms... he didn't suggest you had your cranium inserted into your waste orifice... All he did was frankly and bluntly tell you that you were going off course and that it would be in your best interest to not settle for doing things through the brute force way. In other words he told you "Work smarter not harder".

You take for granted the amazing opportunity you have here. You have dozens of senior coding professionals volunteering to help you, literally at your fingertips. The collective experience of probably 5,000 man-years in the software development industry are only a forum thread away! Do you know what I would have given for this type of interaction when I was in your shoes in my early coding years (pre-internet)? And you go and throw it away by jumping the ass of a person with... 1-3 DECADES of coding experience to offer you... A man that's probably been doing this for a living longer than you've actually BEEN living.... For what? Because he talked to you like an adult instead of like your personal cheerleader... How amazingly and catastrophically short-sighted of you.

Did it never occur to you that just maybe the people here with the badges marked "Expert" "Mentor" "Forum Leader" just might consider themselves colleagues of a sort and look out for each other?

Let's put in terms your school-yard behavior might relate to: Would you as a student walk up to a professor and jump his shit in person the way you did to Bob? If you did, would you expect all the rest of the professors to treat you the same after that, or do you think that action might have repercussions throughout the rest of the faculty and the way they treat you?

I'm done with this thread now. <unsubscribing>

This post has been edited by tlhIn`toq: 20 June 2012 - 05:41 PM

Was This Post Helpful? 3
  • +
  • -

#43 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 07:02 PM

You are making a LOT of presumptions that don't follow my posts well. You are reading what you want in to it, and that is fine. That just goes to show that YOU cant be adult and rational enough to take the posts for what they really are, mine as well as Bobs, and you just read whatever you want in to them.

While your coding skills may be above average, your cognitive reading skills are lacking severely. Which is clearly an absolute necessity this day and age. Granted most people just can't read a piece of text online and make sense of the context. Which is indicative of little to no real-life experience --(Outside Star Trek convention's anyway. Maybe I should have written it in Klingon).


Again, Thanks for your help. Take it how you want!!
Was This Post Helpful? 0
  • +
  • -

#44 BobRodes   User is offline

  • Product Manager
  • member icon

Reputation: 606
  • View blog
  • Posts: 3,086
  • Joined: 19-May 09

Re: Integer to 8 checkboxes checked

Posted 20 June 2012 - 07:04 PM

Well, I was going to change "stupidass" to "sillyass" but I forgot. Sorry. :)

Seriously, if you really want to show your appreciation, you can do your best to apply the information given. That's what we expect from a rookie, if he's going to ask us to go to the trouble of helping him. I took exception to your response because it was you not giving your best. So I called you on it, and you sit around blubbering. Sorry if your feelings are hurt, but you see, that wasn't my choice, it was yours. I really don't have the power to insert feelings into people's minds, and wouldn't use it if I did.

As for "scope creep", it's something that we all have to deal with. But I guess you weren't in the mood for any humor. Again, that's your choice, not mine. "I need 80 checkboxes, not 8, there's a good fellow" is a good example of scope creep, just so you know.

So. Your best is pretty darn good, or tlhin wouldn't have gone to all the trouble with you that he did. He went to the trouble of showing you how to engineer your problem in a well-formed manner, and you cut and ran instead of taking a great opportunity to learn something worthwhile. That bugs me, especially because you're obviously capable of better. So dry your eyes, pull up your boots and soldier on...or don't. Instead, take a giant dump on the living room floor, politely thank us for our time, and turn your nose up in the air and humph your way to the exit. Your choice.

This post has been edited by BobRodes: 20 June 2012 - 07:36 PM

Was This Post Helpful? 1
  • +
  • -

#45 KKUSA   User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 24
  • Joined: 14-June 12

Re: Integer to 8 checkboxes checked

Posted 22 June 2012 - 02:24 AM

I appreciate your reasonable response. However, I was doing my best, and implementing what I was being taught the best I could without asking for it to be done for me. If I dont understand something, I dont understand it. If I dont understand it, I cannot implement it in the manner you feel it should be implemented in. ....Sorry

Trust me, I know where you are coming from. There are things that I am very good at,as you are a programming, as well as being well respected on certain forums pertaining to those things, just as you are here. I have had to teach others those skills as well. It is frustrating, I get it, I really do. However, I have never resorted to being rude and condescending to a "student" simply because they do not understand. Nor would I expect you to come in to my forte, and on the first round, expect you to be able to do it.

Contrary to tlhIn's remarks, I am not a child, Im probably as old as you Bob!! I am a well educated adult, who was hoping to find the same, and be able to get through this on a more intellectual level. Im sick of all the BS adolescent behavior you come across on the web. I didnt get my feelings hurt, it just pissed me off and it only reenforced my take on forums like these (or any forum for that matter)....dont bother!!

I do appreciate the help, as I stated previously. Other than a thanks, a few rep points, and putting the material to the best use I can with my understanding of it, I really dont know what more to give. Unfortunately, I dont think it will be much help to others at this point, as I dont see us completing the task set forth in this thread for others to see in the future.

I will agree that my remarks were on the low end of adolescent, and I apologize, however, I dont think you would disagree you acted in a childish manner as well. I personally dont think you were trying to be humorous at all. You were just simply asserting your authority on the subject in a rather crummy manner. Judging by the reasonable person you seem to be, I think you would agree with that.


Thanks again!!
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4