Category Archives: CSharp

C# Programming stuff.

To Set Sail or Not

So I am getting the programming bug again big time… I’ve had it for nearly a year now. It’s always been a higher level interest of mine. I’ve long wanted to be a game programmer… ever since the early 80s and it really took off in the mid 80s when we finally had a home computer, an IBM PCjr. I remember collecting Compute Magazine, which had full programs you could program in the computer… they gave you the full source code that you had to type in, and entering the code in and then tracking down errors, which universally meant typing errors then… but it was fun. I learned a little IBM Basica… which I think I did on my Tandy PC… I made a couple programs, or more like, modifications of programs from those in the magazines back in those days. But I never learned enough to do anything complex from the ground up.

In college, for whatever reasons, I skipped computer courses and steered to other directions, but at Brown Mackie, I did eventually move to get a Programming and Applications degree. The problem of course, was Brown Mackie’s format, and lowering to the lowest common denominator. So you had one month to each class, but if the slowest people couldn’t go along, then the whole class seemed to stall out, and we just never got far into our programming lessons. I wouldn’t feel comfortable searching out a job as a programmer based on what I learned there… heck, I could teach most, if not all the computer related classes I took there just as well if not better than we learned them. This isn’t to say I didn’t have some really good teachers, but they were held back by the text the school used, the slowest students and the format.

Anyhow, time goes on. I teach myself a bit more Visual Basic, some C# and enough PHP to fix a few issues off and on with the blog. I goof around with them some, but then stop around 2006. More time goes on and around 2008 I start looking at the idea of mobile development. iOS development looks to be out as it comes with a few obstacles, a new language or two (Objective C and possibly some COCOA), but the bigger issue would be needing a Mac, which is a rather large investment, plus in 2008 I had more faith in Android. Come 2010 I start looking at the market again, and the job options look good, and I start thinking again about my future as a programmer, and again focus on mobile development. I start really looking at the options, start thinking about focusing on Java (for Android) and iOS.. By 2011 I start looking at Full Sail University Mobile Development program which would give me a Bachelor of Science degree… now a year later I am again considering it.

The problem is a few fold… First I was really burned by Brown Mackie and how they were a rip off, and fear the same thing. Continue reading To Set Sail or Not

Yet Another Program I Want to Make

Oh for the time to actually do some programming.
I was looking at a college schedule, trying to figure out what classes I would want to take. For a single class however, there may be 6 during the same semester, and this is just the day ones, and 3 or so of which I could probably do before I had to go to work myself. To add to the complications you have 5 or 6 subjects to take during the semester so you had to really consult dates and times when trying to figure out which ones to take. I then decided the best idea would be to make a program where I would enter all 6 or so classes for each of 5 or 6 subjects into a program and use it to help avoid conflicts.
I then modified my idea to include warning levels if a class might conflict with work or the time to get to work. For example, I work at 3 PM. It might give a yellow alert when I have an hour and an orange alert at 30 minutes and a red alert at 15 minutes, all configurable for each user of the program.
The idea was further revised when talking with Sara and trying to figure a way that we can both work, both go to school and minimize the time that Ari would have to be watched by somebody other than us. To then the program idea was modified to allow 2 or more people see how much overlap they have and try to minimize it.
The unfortunate thing is that the user will have to enter lots of information. English Composition for example may be offered 12 times during the semester during the time period the user might be able to go. The user has to enter each of those. The user interface will make things easier by allowing the user to “duplicate” an entry and then all they have to modify is the Class ID (the ID given by the school for that specific class at that specific date and time, this compares to the Course ID which is what all 12 of the same class from above would share) dates the class is offered if that changes (class starting and ending dates such as 8/27/07 to 9/13/07), times, days (Mon, Tue, etc.), campus and room information.
I tried finding a program like this morning, but so far I haven’t had any luck, at least not free. Most of what I have seen, free or otherwise is geared to the school itself, not for the student, and none of which seemed to really do what I wanted. So I guess I have another program to add to my programming queue.

Back on the Developer Reading Block

I am getting back to reading Murach’s C# 2005 and Visual C# 2005 How to Program (2nd Edition) (How to Program) as I am finding myself a bit rusty having not programmed anything for a long time. I really need to keep myself doing a little bit every once and a while just to keep my mind fresh with it. I’ve gone on how good these two books are enough that I won’t go on again, but they are seriously great… Now if only I had a slightly better PC with a good DirectX 10 video card and Vista and I could really get cracking with Visual Studio 2007 when it comes out (VS 2007 will work on XP, but it is really meant to be for Vista development)… to be fair, actually my PC is mostly okay, perhaps a bit more RAM, it is my video card that is the problem at the moment.

My Lottery Program Part 4

Continuing my updates on the progress of my Lottery Program, I recently got it to parse the Mega Millions website to get the latest numbers. Basically it gets a text file, which I have yet to get the program to extract just what I want, but I am making progress slow and sure. I am a little rusty as I haven’t been programming like I should on a constant basis. It got me to break out Murach’s C# 2005 and Visual C# 2005 How to Program (2nd Edition) (How to Program), two great books on learning C# (I am guessing they both will be updating for Visual Studio 2007/2008 whatever it may be called, since there seems to be some major advances coming with it).
I really could use winning a small sum from the lottery myself. Beyond the need for new(er) cars, I could also use a good laptop so I could work on my programming lessons and stuff while away from the main PC (such as spending the day at Borders, or during my breaks at work and so on).

What Time Do I Leave Friday Updated

My What Time Do I Leave Friday program had a minor update today. No change to the main program, but the installer no longer chokes if your version of the .Net framework isn’t exactly as needed (sometimes it would have a problem if you had a newer version). It still checks your .Net version, and if you have an older version, it will offer you a chance to download the newest 2.x version… so basically, it is just an installer upgrade. 🙂
It will not download the newest 3.x version of .Net, and it appears it will download the newest 2.x version, run the .Net installer then continue to run the rest of the install. Also, the installer presently only checks if you have 2.0, not if you have the absolute newest version. I may change the value later to be sure you have the newest version, but since the program only requires 2.0 that is all I checked for.
Anyhow, the newest version of the program can be found here. Download the .zip, extract it then run the setup.exe. The program includes a help file to help you use it, though I think it is fairly straight forward.

My Lottery Program, Part 3

What I meant to say in my previous post about my Lottery Program before I got too distracted, was to continue on about selling the program in a few stores that I figure are more or less a lock to get into, short of it being against the rules for them to sell it there. Since we have friends and family that owns stores that sell tickets, I figured it would be natural to start sells there, however I have a couple issues to address before I can do that.

  • My CD/DVD burner doesn’t recognize CDs. Something got messed up with it’s laser alignment or something, I don’t know, so I’ll have to get a new one. I have a few models I am looking at. A Pioneer Black 18x, about ($31), Lite-On LH-20A1H ($33 for OEM, $38 Retail) which adds LightScribe which may be helpful and nullify one of the points below, on up to the Plextor PX-760A ($100) which doesn’t have LightScribe but is faster than the others, and being a Plextor, a bit more reliable. If I was to get one right now, it would probably be the Lite-On with LightScribe, since it save me the expense of…
  • My printer is a Cannon Pixma IP4000, which outside of the USA here can print on printable CDs and DVDs. In the US, they took out two parts and put in a slightly altered front door. So to print on CDs, properly, you need to buy two parts, the roller and the tray. Both are available on eBay and the two parts together will set you back $31, not too bad really (note the link only takes you to the CD tray, the CD tray in question needed for this printer is tray B, but a few of the listings have the roller as well). Details on CD/DVD printing on US IP3000/4000/50000 are available at the link provided. The nice thing is that this provides for full color printing on CDs and DVDs that are inkjet printable, unlike LightScribe which is monochromatic, though some of the newer ones have a background color other than just gold. It is probably recommended to get anyhow, even with a LightScribe burner, there are times when either you want color, or like me you have a bunch of inkjet printable disks.

Continue reading My Lottery Program, Part 3

More on My Lottery Program

Continuing where I left off with regards to My Lottery Program that I want to make.
It also occurred to me while starting out the design there are several stores that I could sell it in if I can get it to a semi-professional status. All of them sell lottery tickets, so it would be a natural for them to have a program, made by somebody in the family non-the-less, to help people pick ticket numbers. It may entice them to buy more tickets, which equals more revenue for the stores. Unless of course there are rules against having such a program in a store that sells lottery tickets.
In regards to Lottery Wheels, another example. Let’s say you have 7 numbers you want to play on the Mega Millions (not counting the Mega Ball) you will end up playing 9 tickets to guarantee a win of 4 numbers. Again, 4 of the 7 numbers you picked have to come up, so the guarantee just says that one of the tickets will be a winner in the event 4 of your 7 are drawn, which you can’t guarantee with just a pure random selection.
Random numbers is such an interesting concept. You would think randomness would be easy to achieve, but say if they drop all the numbers into the lottery bin in the same order, at the same rate every time, and the paddles in the bin are in the same spot every time, your ability to be truly random, even with a machine like a lottery machine goes down some. Computers have an even harder time generating truly random numbers. The Free Cell game you have on your computer has 1 million different deals (on XP anyhow, only 32,000 on older versions, see the previous link for more details of the number of deals and solvable/unsolvable ones). Nobody programmed all 1 million deals in (or 32,000 for that matter0, laying out what order each card will come out in. The way they archive it is that they give the random number generator a number called a seed, and from there it generates a random pattern, except after the first time, the same seed results in the same pattern. Generally to pull a “true” random number the computer will use the time clock, the problem is, two otherwise equal PCs doing the same task at the exact same time would get the same results, so you are once again not truly random, though this is normally random enough for most things. There is a logical reason for computers to be so predictable with random numbers, and that is testing. By constantly giving it the same set of seed values you can predict how it should behave and find problems with other aspects of a program or something before seeding it with a truly random number.
Anyhow, there are some features that I plan on adding that I haven’t seen in any of the other programs yet, but then again some of them don’t have free time limited demos, so I can’t be sure, I don’t recall seeing these features on any of their feature pages. Since they don’t mention it, I won’t mention this feature until the program is out since this may make me a unique entry in the market place.

My Lottery Program

While checking out the USA Mega site yesterday, which I mentioned in my lottery post, I was browsing around I and found their Mega Millions Statistics. It seems some numbers come up more often than others, a statistical anomaly one would suppose, but one that is there none the less. For example, 25 has came up 28 times in the last 195 drawings, 07 and 36 27 times, while 47 has appeared only 9 times with 19 having been pulled only 7 times. This got me thinking that it would be interesting to take a program that allows the user to filter certain numbers out of a list when it generates a the lottery number, further the user would be able to make a list of numbers they wanted to either be weighed more heavily, or a short list of numbers that they wanted to pick from. Say they picked a short list of 8 numbers, the program then would generate numbers just from that list.
Continue reading My Lottery Program

Microsoft’s Beginner Developer Learning Center

Microsoft has launched their Beginner Developer Learning Center which takes people from no programming experience to a basic level of experience. It teaches Visual Basic and/or C# whichever one want. The first thing you decide is which track you want, Web Development for dynamic web sites, web applications and services, or Windows Development for making Windows applications and games (they don’t have a game tier, at least yet). After deciding which track you want, you choose a tier. Tier 1 is an introduction to the basic concepts and an introduction to the language of your choice. Tier 2 gets you grounded in the basics of .Net programming and gets you to make an basic application in the language of your choice. Tier 3 gets into data access, data binding and other such concepts.
I haven’t had a chance to use the site to learn from yet myself, but it looks like it will be a nice site to use. It however won’t beat Murach’s C# 2005 and Visual C# 2005 How to Program (2nd Edition) (How to Program), both of which I highly recommend, but the site is free and seems to do a good job of getting the basics.

What Time Do I Leave Friday Updated

I made a couple minor changes to my What Time Do I Leave Friday program that I made. This brings the beta from 0.5 to 0.5.3. One of the changes was behind the scenes and doesn’t matter to the end user. The other change was having the program check to see if the user entered a digital time in the two main text boxes on the main form, if they did it offers them a chance to go back and edit it or accept it. I am not overly happy with the method used at the moment, and will be changing that soon. I’ll probably add something to the Validator class so I can handle it on more forms. A third change was to have the program start centered on the screen rather then in the upper left.

What Time Do I Leave Friday Ready for Testing

My What Time Do I Leave Friday program is ready for testing. Contact me for the setup file. I can either send it as a zip file, where you unzip it and click the setup.exe, or just send the setup.exe file itself. The zip file is 188kb (under a half minute for most people) and the setup.exe itself is 204kb (under a minute for most people) 488kb (under 2 minutes for most people with dial up, and very well under a minute for cable modems) (edited to add size change do to adding the help file which I forgot the first time).
As noted before, you will need Windows 98/ME/2000 or XP to run the program, and it will need the newest version of .Net installed, which you should be able to get from Windows Update. If the program or installer complains about you not having the newest .Net, let me know and I can send you a file that will install it for you.

What Time Do I Leave Friday Ready for Testing this Weekend

My program What Time Do I Leave Friday will be ready for testing this weekend (26th or probably 27th of August). Let me know if you want to give it to help out and test it out.
The system requirements are a Windows PC (likely will need Windows XP or Windows 98/ME as it needs .Net 2.0, which it should download from Microsoft if you don’t have). If you are running XP, then you should be golden, although I see no reason why a machine that runs 98/ME shouldn’t be able to handle it.
What I need the testers to do is, run the program, and report back about the program. If it gives a false value or whatever. Give as much detail on any errors or false values as you can, such as what you were doing, what numbers you entered into where and the like so I can try to recreate the problem here and fix it.

C# Help Needed

If there are any C# programmers out there reading this, perhaps you can help.
First I’ll repost a screen shot of the program I am working on:
Screenshot - What Time Do I Leave Friday - Main window
Under the Action menu, there is an option to change the Standard Work Week (by default set to 40:00). When the user selects that, the standard work week text box changes from read only and a save button (not seen on this shot) becomes visible and active. The user then can edit the standard work week, save it and then have the program calculate what time they are to leave Friday (or whatever their last day of work is). That woks as expected. The problem comes up if they edit the standard work week, but don’t save it and then hit calculate. It will calculate based on the last saved (or if never saved, the default) standard work week, which may not be what they typed into the text box.
What I have in place now is a message box that pops up if they try to calculate before saving their work. I currently am using an OK button message box, where if the user selects OK it saves the standard work week and then performs the calculations. Ideally I would like a Cancel button to take the focus back to the text box and wait for them to save it. Then the program could either continue performing the calculations, or the user may need to hit Calculate again.
Here is some code to give an idea of what I am doing:
Continue reading C# Help Needed

New Feature Being Added to What Time Do I Leave Friday

I thought about the fact that some people may not have the time they worked so far in the week, just a time sheet of times in and out. I don’t want to turn this into a time clock application, but I decided that I would add a Hours Worked So Far Calculator to the Action menu. I’ll also add unpaid breaks to the Lunch window to cover up to 2 unpaid breaks (so far as the program is concerned, it will basically combine them into one Lunch/Breaks time since it isn’t a time clock, it doesn’t need those details to work the time out). After that, the program should be feature locked.
I have removed most of the bugs that I could find so far, and none of them were show stoppers, most just annoyances. For example, if the user wanted to enter a lunch and hit Save before entering anything, a box would come up telling you that something was a required field. After the user hit OK on that error box, the error box went away as it was supposed to, but the lunch window went away as well. Not a show stopping but, but a fairly big annoyance having to click the Add Lunch button again then remember to hit the time(s) in.
An example of a small bug was canceling adding a lunch would sometimes result in an error coming up that the “Index Was Out Of Bounds.” This was caused by the fact that the lunch was still be calculated, now based on a blank value (called a null), so when the program tried to split the time based on a “:” or a “.” there was none there, so there was nothing past it. It may seem complicated to the non-programmers out there, but it was a fairly easy thing… actually, I am not sure how I missed it.
Another small bug was if the user just entered a time without the “:” or “.” separator, it had problems, solved simply by having the validator make sure there was one in there. (It already was checking to see if one was there as a valid entry, it just didn’t do much with it from there… actually, those reviewing the old code will see it allowed for 1 separator or less to pass, I just changed the <= to == so it had to be 1 and adjusted the message box to have the user check to be sure a separator was there.)

What Time Do I Leave Friday Screenshots from Beta 2

Here a screenshots of Beta 2 of my program, What Time Do I Leave Friday (my first semi-practical program):

The main screen:
Mian screen of my program, What Time Do I Leave Friday
Here the user enters the total hours they worked so far this week (using the action menu they can change the standard work week hours from 40:00), they also enter the time they got in Friday (or whatever their last day of work is) and a lunch if applicable. It will then display what time they are to leave Friday.
I will probably change the AM/PM radio buttons to a combo box.

Here is the lunch screen:
Lunch screen of my program, What Time Do I Leave Friday
Here the user can choose to enter their lunch time (for example 0:30 for 30 minutes) or put in their time out to and in from lunch.

Here is the main screen after being used (I typically don’t take a lunch, but for this example I entered one):
Main screen in use, after entering lunch and other information for my program, What Time Do I Leave Friday

There are only a few things to clear up before it enters public Beta. (For those who don’t know, beta is a stage of software development before the program is ready for distribution… the link gives better details.)
I am working on making a new page for the program (as you might see by the menu on the left, where it currently lacks a link), and there will be a separate page for the code itself.

You Too Can Make XBox 360 Games

Anyone using Visual C# 2005, Express Edition can now make games for the XBox 360!
There is a small licensing fee to pay per year, $99. I am guessing the main part of that is a place to host the game so your XBox 360 can access it. It also gives you access to more tools and help.
Game development with the free tool set will also allow games to be made for Windows XP SP2 and Windows Vista, so if you don’t want to make games for the XBox 360 and pay the fee, you don’t have to.
More details and tons of links here.

Program Now At Beta 2

My What Time Do I Leave Friday program is now in it’s second beta. I added the ability to put in a lunch and to change the standard work week from 40. It will also give you a message if your worked hours are over the set standard work week. The box that pops up to get lunch information can take it in two forms, total time taken, so say you take a 30 minute lunch, you could type 0:30 in the box or if you rather have it calculate the lunch time taken, put the time out to lunch and the time in from lunch. To keep things from being confused, it will allow you to enter only one or the other.
I will update the page about the program soon with the new source code… or make another page, I am not sure yet, right now I am going to bed.
There are a couple bugs to get out of the system. For example, after the message pops up about working over the hours needed for the week, it still keeps going. I could easily close the application, but I would rather just clear everything and start afresh, unfortunately if I do clear stuff I get other errors.
A few changes are still in the works. I may add something to show the lunch time taken on the pain program page, but I am not sure about that yet, it would probably help the user to see a confirmation of the time. I also want to make it so if you change a text box, the text boxes that show the calculations clear. Both of these will be real easy to do, but I am too tired right now…
I’ll update later with more.

My First Semi-Practical C# Program

I made my first semi-practical C# program over the last couple of days. I probably would have had it done in less then one day had I the time.
Here is a screenshot:
Screenshot of What Time Do I Leave Friday

In short here is what the program does:
The user enters the hours they worked so far out of 40. (The second version will allow you to change the hours in the work week.) They then enter the time they clocked in Friday and it gives the time they should leave. (The second or third revision will add the ability to add lunch time to Friday so the user can calculate past that… I don’t take lunch’s normally so I didn’t add it in the first version here.)
I’ll probably post the code to a page about the program. Keep an eye out for another post soon. I still have a few things I want to clear up in the code before posting it.


The code is here.

The main reason I say semi-practical, beyond the fact it needs the two primary enhancements before it would be useful to those beyond me, is that I don’t have a way of actually using it at work. I would need a laptop to put it on… (a laptop that uses Windows XP, has .Net 2.0 and the like… though the program should technically work on any machine having .Net 2.0).

Refactoring Rocks

I just did the first part of Exercise 6-1 in Murach’s C# 2005, and while I had read the part earlier about Refactoring, it didn’t hit me at how very cool this part of refactoring is until I actually did it. It is an amazing time saver, and can undoubtedly make for far neater, reusable, and more readable code. I have used the part of refactoring, even before reading about it, when changing the name of a variable, but this is the first time I ever used it to extract a method.

Why Didn’t I Remember or Think of That?

I was working on Exercise 4-2 in Murach’s C# 2005 which at one point has you figure out how to display the largest, smallest and mid point of a series of invoices. Finding the largest is fairly straight forward, assume it is 0 at the start and compare it using Math.Max (at this point we can’t use the if or any other control structure, just the math class). The smallest invoice was the first trick, and they give a hint, but for some reason I couldn’t figure out what they meant by using the “MaxValue of the Decimal class.” Why I couldn’t figure remember that a member is something that follows a dot operator is beyond me, but the solution was simple enough in the end, decimal smallestInvoice = decimal.MaxValue; to set the high number for smallestInvoice and then compare it to the invoice total using the Math.Min.
The next point of confusion for me was finding the mid point. Perhaps it is because I was woke up at 6 a.m. after going to bed at 2 a.m., but for the life of me I couldn’t figure out how to find the mid point in a set of numbers. I was like “I know the mid point of 1000 and 500 is 750, but how do I know that using math?” For some reason I kept attacking it from the wrong direction and eventually had to use the Internet to find the formula. At this point I smacked my head and thought “why didn’t I remember or think of that?”
Incidentally, in case you forgot, the formula is (X+Y)/2… though most of the examples on the Internet were for number lines, such as finding the midpoint of say (12,3) and (4,7) which is (8, 5)… thinking in terms of Algebra that becomes (x1,y1) and (x2,y2) = (midX,midY) and the formula for that is midX=(x1+x2)/2 and midY=(y1+y2)/2.. all of which I note here mostly for future reference for myself.