zachattack05 70 Posting Pro in Training

The % simply returns the remainder of the division of the first and second number.

So if i = 25, then 25 % 2 would return 5, which doesn't meet either of your if statements.

Change your code to this:

        Console.WriteLine("");
        Console.WriteLine("Problem #3 For loop - Add Up the Odds or Evens");
        Console.WriteLine("");
        Console.WriteLine("Please select 1 for the sum of even numbers or select 2 for sum of odd numbers");
        string usrin = Console.ReadLine();
        int usrinnum = int.Parse(usrin);
        int sumeven = 0;
        int sumodd = 0;
        int[] Numbers = new int[6] { 25, 26, 27, 28, 29, 30 };
        if (usrinnum == 1)
        {
            foreach (int i in Numbers)
            {
                if (i % 2 == 0)
                    sumeven += i;
                Console.WriteLine("The sum of the Evens is " + sumeven);
            }
        }
        else
        {
            foreach (int i in Numbers)
            {
                if (i % 2 != 0)
                    sumodd += i;
                Console.WriteLine("The Sum of the odds is " + sumodd);
            }
        }

Read here: https://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx

zachattack05 70 Posting Pro in Training

Yes, different name spaces in one project are allowed. :)

I think of namespaces as a folder tree with each "." defining a new folder. I use them a lot for organizing my code.

zachattack05 70 Posting Pro in Training

No problem.

zachattack05 70 Posting Pro in Training

Try WriteLine instead of Write. Or try writing "\n" for a new line.

zachattack05 70 Posting Pro in Training

Sure, just include the "Export to XML" feature for the user if they really want that.

zachattack05 70 Posting Pro in Training

XML works, but I avoid it like the plague.

XML files are bloated for the sake of "human readability."

I always use straight up binary serialization. You could always include a "export to XML" feature :)

zachattack05 70 Posting Pro in Training

The first thing I ever programmed was a magic 8 ball :)

I guess it depends, you could scour source forge for an open source project that needs help (though I think a lot of that is C++ not C#, and not usually .NET) or try Google Code for the same.

Have you tried client/server stuff? If you want a headache and lots of head scratching that will make you learn, socket programming can be fun (and frustrating) if you have a network to play on.

You could also try CRUD development, and create a program that stores data, analyses it and charts it etc...

Some other generic ideas:

* A journaling program that uses rich text, encryption to keep entries secure and multiple users.
* A program that analyses vehicle gasoline performance based on mileage, tire, oil and other maintenance.
* A program that plays Netflix movies (Netflix API and Developer Network)
* A MP3 player
* A video chat program
* A video player
* An image editor
* A web browser

Just some ideas :)

zachattack05 70 Posting Pro in Training

thines has a good suggestion.

If you are going to be holding many different pieces of data I would recommend delimiting the data in some fashion or otherwise structuring your file so that there is a "table of contents" so to speak so you can find where certain data is.

Unless it's absolutely necessary to store the data in a text file, you could serialize your data which might be easier.

zachattack05 70 Posting Pro in Training

Panels are okay, just remember though, the anchor is only for the the control's parent container. So...if, for example, you have a form with PanelA and a label control LabelA inside that panel, when you set the anchor on the label, it will adhere to the PanelA rules.

I attached an example to show what I mean.

In the example, you can see that the label ignores the size of the window even with the anchor set. It does that because the anchor is relative to the panel, and the panel is set to Top, Left for both. If I changes the panel to "Dock Fill" the form, or if I changed the anchor of the panel, the label would react differently.

Honestly, I find the programming logic, the code writing or whatever you want to call it, MUCH easier than form design...I HATE messing around with layouts...it's so frustrating.

zachattack05 70 Posting Pro in Training

The label at the bottom is probably moving because the anchor for it is set to "Top, Left". Try changing it to "Bottom, Left, Right" or something along those lines to keep it in place.

The calendar is probably having the same problem. Maybe set it to "Top, Left, Right"

If you already have the anchor set correctly, the next question I would ask is, are you using any layout tables, panels or anything like that?

zachattack05 70 Posting Pro in Training

Hello Guys, I am building an application using C# as a front end(VS 2008).
I have a main form which contains a main menu and other controls like labels, calendar etc.. the main form I am talking about starts as full screen, my problem is when I drag/drop/edit controls in design mode and run the application, the controls are not in the same place as i putted them in design mode. [i.e] I placed a calendar in design mode in the center of the form, and another label as a footer, so when i run the application i found the calendar and the label went up few inches up.

Any help would be appreciated.

Can you post a screenshot of the problem and any code that you think might be suspect?

If you are using a MDI, the menu might move off of your form and onto the parent form which could make it look different.

zachattack05 70 Posting Pro in Training

Question 1: Why a console app and a winform app? I think it might be easier to have just a winform app and that's all unless the console one does something special, but I don't see why it couldn't be combined.

Question 2: What's your goal in doing something like this? Seems odd to me. While it can be done, there might be a better, easier, more elegant way of doing whatever it is your trying to do.

zachattack05 70 Posting Pro in Training

Could also be it's the middle of the day and people are working.

Care to share your solution to the problem for others?

zachattack05 70 Posting Pro in Training

Do you need to have both on their own form? You could have one form, and have the form show a panel that holds a custom control and just show and hide the different panels, that way it's all on the same form but "appears" to have two forms. It also prevents that annoying fade in and fade out effect for vista users. Just an idea...I use it a lot for "control panel" or "settings" forms.

I can post an example project if you would like to try that approach.

zachattack05 70 Posting Pro in Training

I don't know if it necessarily requires less work or more work, or even the same work. C# and C++ are tools, and each tool has a niche. C# can be used for web applications that run on IIS servers and (as far as I know) C++ cannot. I don't write in C++, mainly because Windows is the target platform, all Windows machines come with .Net now and I honestly don't know enough about C++ to effectively write software. I rely on the CLR and the framework to do work for me that I would otherwise have to do by hand. To me, C# is great and does what I want, quickly and effectively. I've never found something I couldn't do in C#. I may not understand how it's done, but I know it can be done.

Just another 2c worth :)

zachattack05 70 Posting Pro in Training

I believe what you are probably looking for is this.

Hope that helps :)

zachattack05 70 Posting Pro in Training

I would say no it doesn't count.

C++ and C#, while similar, are different languages. I can't program in C++, but I can in C#. I don't know what header files really are, no idea how to even create a window in C++. If you want to work at a job that requires C# experience, and you only have C++, if I was a project manager or working in HR, I wouldn't hire you.

I would say that 3+ years of C# experience means just that. Either working on a project (or many) that were written in C# for at least 3 years. Some places might include school work, but it depends.

I think that personal projects can count as well. If you have source code that you can part with and a compiled, finished project, share it with them so they can see that while you are "self-employed" or "self-taught" you actually can provide something to show for it.

Just my 2c worth.

zachattack05 70 Posting Pro in Training

To be honest I don't know if it's serializing and deserializing correctly. It appears that you are serializing to a file on the disk.

Clean your solution, delete the file at "K:\MiniSteam\ChessGame\Replays\Replays.dat" start the program in debug mode, do something to make the application serialize and see if the file is created. If so, it's serializing something.

How you use the data afterwards is up to your application's logic.

Since I really don't know what your ultimate goal is I can't really comment on if it "works" or not. The act of serializing "something" is working if the file is made and actually contains the data you need to use.

My suggestion would be to see if you can use the data in the file, if you can, it works, if not, it's not. :)

NewOrder commented: thanks for the help +0
zachattack05 70 Posting Pro in Training

Ahhh I see it now.

Because your class named ClassMoveToSerialize contains a field to hold another class instance called Class2, that means Class2 also needs the serializable flag.

Add the [Serializable] flag to Class2 as well.

NewOrder commented: Thanks for helping me with seriliazation +0
zachattack05 70 Posting Pro in Training

Add another "=" to your condition.

one = sign is assignment, you can't do that in the if () condition.
two = signs is used to compare.

You should use:

if (this.LblANDa.Text == "1")

instead.

:)

simagen commented: thank you +1
zachattack05 70 Posting Pro in Training

Add the [Serializable] flag to your ClassMoveToSerialize class if you haven't already.

Also, what exception are you getting?

zachattack05 70 Posting Pro in Training

If you have divided your application up you can create a new solution that is a custom updater. Add the project(s) that you need to update to that solution as well and then all you would need to do is have your updater do a few things:

1. check to make sure the program isn't running
2. find out where the file is that needs to be updated
3. delete the old file (or mark it with the .old extension in case the update fails)
4. copy the new updated file to the same location as the old one
5. clean up any old files and close the updater

It sounds easier than it is, but it's not really that hard either.

If your application is only one file though (a .exe) and no dlls or supporting files, you just need to re-release it because technically that's the update.

Patching is different than updating, but are kinda the same result. Patching is way over my head though. But it can be done, I think there's a way to make installer files that only patch existing installations, but I'm not sure how to do it.

zachattack05 70 Posting Pro in Training

Eh just realized you need to clear the combobox if you run it twice...easy fix...just wanted to point it out

zachattack05 70 Posting Pro in Training

EDIT: Product field should be called Quotient to be accurate. Sorry for any confusion there :)

No, || wouldn't work for absolute value in C#, I believe it's Math.Abs(x);

MSDN: Math.Abs Method (Decimal)

Like I said though, about listing possibilities...whatever you want is fine, but you need some kind of limiter otherwise the computer will loop infinitely.

Here's some code to show what I would do (it's rough, no promises):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ResolutionCalculator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private int[] GetRatio(int val1, int val2)
        {
            //find the difference
            int Difference = val1 - val2;

            //get the abs value
            int AbsDifference = Math.Abs(Difference);

            //find the first ratio number
            int Val1Ratio = val1 / AbsDifference;

            //find the second ratio number
            int Val2Ratio = val2 / AbsDifference;

            //write the ratio to the label
            labelRatio.Text = Val1Ratio.ToString() + ":" + Val2Ratio.ToString();

            //return our ratio
            int[] Ratio = new int[2];
            Ratio[0] = Val1Ratio;
            Ratio[1] = Val2Ratio;

            return Ratio;
        }

        private void GetSimilarResolutions()
        {
            //our limiter
            int i = 0;

            //our maximum iterations
            int Iterations = 5;

            //our first value
            int val1 = int.Parse(maskedTextBoxLength.Text);

            //our second value
            int val2 = int.Parse(maskedTextBoxWidth.Text);

            //our ratio
            int[] Ratio = GetRatio(val1, val2);

            //the last value of the length
            int LastLength = val1;

            //the last value of the width
            int LastWidth = val2;

            //the string to hold a resolution
            string Resolution; …
zachattack05 70 Posting Pro in Training

Not sure the reliability, but maybe useful: Video Rez from Wikipedia

zachattack05 70 Posting Pro in Training

I would imagine the first thing you would need to do is figure out what the ratio is.

Determining ratios is easy, its basically the percentage of each other. Here's an example:

Back in the days of XVGA and SVGA screen resolutions were usually close to the standard 800 x 600. This is a ratio of 4:3. What that means is, for every 4 units of measure in width, there are 3 of the same units of measure in length.

Some people might say that a ratio is a fraction...that's true, kinda. When talking about a 2 dimensional plane (length and width ONLY or only 2 objects) then it can be thought of that way. But if you had a ratio of 4:3:1 or something, that's different.

Here is how you find a 2D ratio (which is probably what you want):

using 800 x 600 as the example. First we find the absolute value of the different between the two numbers, in this case 200. We then divide each by that number:

|(800-600)| = 200
800/200 = 4
600/200 = 3

4:3 is your ratio for 800 x 600.

Here's another example:

1024 x 768:

|(1024-768)| = 256
1024/256 = 4
768/256 = 3

4:3 is the ratio again.

so that means if 800 x 600 and 1024 x 768 have the same ratio, if you increase 800 and 600 and respect the ratio, …

zachattack05 70 Posting Pro in Training

Well, I would say there are two steps involved here.

  1. Convert your text into an image (bitmap)
  2. Alter the image you created and display it in the picturebox

You will probably (for clarity in my opinion) need two methods, one for each of those tasks.

For the first step I would check out the Drawing namespace. You need a method that returns a Bitmap object first. You can add the text from your textbox to the bitmap with the Graphics.Drawstring method. There's a (somewhat) decent example of this being done here.

For the second step, you need to modify your new bitmap object. This is the tricky part. I would suggest you start here.

I've never done anything like what you are doing though. Those are good starting points though.

Try searching Google for "Image Processing in C#" also for more ideas with the second step.

Those are just my suggestions, someone might have better ones.

zachattack05 70 Posting Pro in Training

So...you want to take text from the box and turn it into a graphical representation with noise in it?

Or do you want to have an image appear and have the user enter what they see?

zachattack05 70 Posting Pro in Training

Might I suggest you use a MDI form? It would make getting that list very easy.

As for finding the last active form, try the Activated event instead of LostFocus and GotFocus.

From MSDN:

The Enter and Leave events are suppressed by the Form class. The equivalent events in the Form class are the Activated and Deactivate events. The Enter and Leave events are hierarchical and will cascade up and down the parent chain until the appropriate control is reached. For example, assume you have a Form with two GroupBox controls, and each GroupBox control has one TextBox control. When the caret is moved from one TextBox to the other, the Leave event is raised for the TextBox and GroupBox, and the Enter event is raised for the other GroupBox and TextBox.

For your reading pleasure:
Activated
Deactiveate

zachattack05 70 Posting Pro in Training

Not sure how to answer your question, but as a bit of info (only in case you didn't know) MSDN states that applications shouldn't be developed using this technology anymore and instead should be using WCF. MSDN Website.

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Just a FYI. :)