lxXTaCoXxl 26 Posting Whiz in Training

Also, for Square Root, Exponents, and so on, you'll have to perform the math in the same way I demonstrated; however there is one rule. You must perform the math on the number to be manipulated before performing the math on the manipulation. For example:

5 + 8 + SquareRoot(9). We know the answer to this is 16. Our computers know this as well, however they can't tell you the answer just by looking at SquareRoot(9). They need to be told how to calculate that. So for something involving manipulation of a number you would perform the math in steps. Shall I explain?

With my example 5 + 8 + SquareRoot(9) we would first solve 5 + 8, giving us 13. Then we would solve for the square root of 9; which brings out new expression to 13 + 3. Thus giving us the answer of 16. But say the user wants to make it 5 + 8 + SquareRoot(9) + 4, which is equal to 20. To do this, we would solve the Square Root of 9 before performing math on 13 + SquareRoot(9). Then we would perform the math. So using the same algorithms I provided earlier (switch logic) you would add in an extra button called SquareRoot (or whatever you want to call it) that would serve as a notice to perform Square Root math. Meaning you would add a new variable called (for example) SpecialMath as type boolean. Then if SpecialMath is a true value, see …

lxXTaCoXxl 26 Posting Whiz in Training

I did everything but fix the display string for you. The display string will keep adding the incorrect values, but the math stays correct. :)

Fix the display problem and you'll have a functioning calculator. :)

        private double Value1 = 0;
        private double Value2 = 0;

        private string Value2StringTemp = "";

        private int CurrentOp = 0;
        private int NextOp = 0;

        private void ButtonOne_Click(object sender, EventArgs e) {
            Value2StringTemp += "1";
            mathPerformed.Text += Value2StringTemp;
            Value2 = Convert.ToDouble(Value2StringTemp);

            CurrentOp = NextOp;
        }

        private void ButtonTwo_Click(object sender, EventArgs e) {
            Value2StringTemp += "2";
            mathPerformed.Text += Value2StringTemp;
            Value2 = Convert.ToDouble(Value2StringTemp);

            CurrentOp = NextOp;
        }

        private void ButtonPlus_Click(object sender, EventArgs e) {
            CurrentOp = CurrentOp == 0 ? 1 : CurrentOp;

            switch (CurrentOp) {
                case 1: Value1 += Value2; break;
                case 2: Value1 -= Value2; break;
                case 3: Value1 *= Value2; break;
                case 4: Value1 /= Value2; break;
            }

            NextOp = 1;

            Value2StringTemp = "";
            mathPerformed.Text += " + ";
            currentAnswer.Text = Value1.ToString();

            Value2 = 0;
        }

        private void ButtonMinus_Click(object sender, EventArgs e) {
            CurrentOp = CurrentOp == 0 ? 2 : CurrentOp;

            switch (CurrentOp) {
                case 1: Value1 += Value2; break;
                case 2: Value1 -= Value2; break;
                case 3: Value1 *= Value2; break;
                case 4: Value1 /= Value2; break;
            }

            NextOp = 2;

            Value2StringTemp = "";
            mathPerformed.Text += " - ";
            currentAnswer.Text = Value1.ToString();

            Value2 = 0;
        }

        private void ButtonDot_Click(object sender, EventArgs e) {
            Value2StringTemp += ".";
            mathPerformed.Text += Value2StringTemp;
            Value2 = Convert.ToDouble(Value2StringTemp);

            CurrentOp = NextOp;
        }

        private void ButtonEquals_Click(object …
lxXTaCoXxl 26 Posting Whiz in Training

Okay, reading over your source code there are a few things I can point out to you that you might be interested in for shortening the amount of line's you'll have overall.

1) Since you're requiring access to Form1 in Form2 you can create a variable of Form1 in Form2 then request it in the constructor; this would help with assigning the whole Form2.Form1 thing. Also to get rid of the conditional where you're checking to see if Form2 has been disposed or not, it's not required. Instead move your declaration of Form2 into the area where you're calling Form2.

        // Inside Form2.cs
        private Form1 MainForm;

        public Form2(Form1 f1)
        {
            this.MainForm = f1;
            InitializeComponent();
        }

        // Form1.cs:
        public partial class Form1 : Form
        {
            /* Form2 frm2 = new Form2(); -- Remove this. */
            public Form1() {
                InitializeComponent();
            }

            public string getTextButton() {
                return callform2.Text;
            }

            private void callform2_Click(object sender, EventArgs e) {
                Form2 f2 = new Form2(this);
                f2.Show();
            }

That will ensure that Form2 is never disposed when called since you're only calling it from there. You can just declare, initialize, and use it from the method you're calling it in.

2) You can get rid of 'if', 'else if', 'else' on the 'opmode' variable and use switch structure. If you're unfamiliar with switch structure below is an example using your variable:

    switch (opmode) {
        case 0: doSomething(); break;
        case 1: doSomethingElse(); break;
        case 2: doSomethingDifferent(); break;
    }

3) When performing math of …

lxXTaCoXxl 26 Posting Whiz in Training

Try removing the try catch block:

private void linkLabel1_Click(object sender, LinkLabelLinkClickedEventArgs e) {
    Process.Start("http://www.website.com");
    linkLabel1.LinkVisited = true;
}

If that doesn't work then switch over the event to the simple clicked event:

linkLabel1.Click += new EventHandler(linkLabel1_Click);

private void linkLabel1_Click(object sender, EventArgs e) {
    Process.Start("http://www.website.com");
    linkLabel1.LinkVisited = true;
}

It's probably going to have to be switched over to the standard click event.

lxXTaCoXxl 26 Posting Whiz in Training

Create your picture boxes, and set their background images to the correct images. That's the solution I would use with the way you've phrased your question. If this is not what you want then please try clarifying your problem.

lxXTaCoXxl 26 Posting Whiz in Training

hey dude

&&-means logical AND operation
||-means logical OR operation

give problem is
a=true;
b=false;
c=false
then
d=( a && b ) || c
//a && b-means (true && false)
//&&-return true when both input are true here one is true (a) another
//one is false(b) this will return false
//in next step it calculate false || C
// ||-return true when any one of the input true here both are false (a&&b)
// and c so result false will assigned to d
hence result d is false

I believe that was my response just in shorter and more confusing words? O_o

lxXTaCoXxl 26 Posting Whiz in Training

Sorry to hear that. :(

Well let us know if you need help with the next assignment (be sure to create a new thread) and we will help you through it. Be sure to mark this thread as solved since the deadline is passed, unless you wish to continue trying to create this project.

Jamie

lxXTaCoXxl 26 Posting Whiz in Training

Wow, well in that case I would definitely read up on my basics and quick. I hate teachers like that. Good luck to you, if you need further information then just post back here and we'll try to help you.

lxXTaCoXxl 26 Posting Whiz in Training

&& is the and operator; the way it works is the value it returns is true when both sides of it are true, and only when both sides are true, any other time it returns false.

|| is the or operator; I forget how it returns until I'm actually using it for some reason, but it's about like saying if (x is > y or x is > 15) doSomething();.

! is the not operator; this basically returns the opposite of the boolean value you assign it to. When used in conditionals if (x != 10) this basically saying that if x is not equal to 10 (any other value than 10) to execute the code in the if block.

So basically if I remember correctly the or operator returns true only when both sides are false. So when a is true, b is false, and c is false; the statement (a && b) || c should return false.

The if () conditional only checks for boolean values, even when using integers or strings it returns a true or false value to the if. When the value is true (condition met) then it executes the code block below it. If it returns false (condition not met) it skips the following block of code and checks for an else if or else block.

That should sum it up quite decently, if you need anything else just let me know. Please just note, I'm not the best …

mani-hellboy commented: You told with exaple and it like "thalaiya suthi mooka thodura mari" tamil proverd its waste I told sort and opt answer -1
Philippe.Lahaie commented: (the or operator returns true only when both sides are false) wrong :S -1
lxXTaCoXxl 26 Posting Whiz in Training

You can calculate speed with ease. Speed in any form is calculated by dividing the distance traveled, by the time it took to travel that distance. However, I do believe this project seems a little difficult for a complete novice? I'd seriously recommend a new teacher. Is this even for a class, or is it just so you can learn? Because if it's so you can learn the C# language then just start out with some simple stuff. Getting text from text boxes, converting input from a textbox into an integer for math calculations, using arrays, vectors, locations, learn about the basics. I don't know what kind of teacher would tell a student to develop a full blown application of this nature with classes just beginning earlier this month all over the states.

public float CalculateSpeed(float Distance, float Time) { return Distance / Time; }

Jamie

lxXTaCoXxl 26 Posting Whiz in Training

Mark thread as answered to close the thread. I was actually interested in this though; thank you for posting this.

lxXTaCoXxl 26 Posting Whiz in Training

Your application may need reference to B.dll as well as A.dll since A.dll is referencing B.dll; I'm not 100% sure, but if you haven't tried it then do so. Sometimes the answers we're looking for are the simplest ones we don't try because we think that it can't possibly be the solution.

lxXTaCoXxl 26 Posting Whiz in Training

you can do this in several ways... You can use this.hide or like kam said minimize it at load, and there a few more ways as well. Sorry for the bad spelling and grammar but I'm on my touchpad lol


this.visible = false;

all ways of doing this will all be on load event

lxXTaCoXxl 26 Posting Whiz in Training

Visual Studio (Express, Professional, Ultimate) 2010
#Develop
Notepad++
Microsoft Word
Wordpad
Notepad
Sticky Notes

Any application with an open text field will work, you just have to find a compiler witch is why most people just use Visual Studio or #Develop.

lxXTaCoXxl 26 Posting Whiz in Training

Okay, as I just stated, simply add Environment.NewLine to the end of the statement.

private void Button_Click(object sender, EventArgs e)
{
textBox2.Multiline = true;
timer1.Start();
}

private void Timer_Tick(object sender, EventArgs e)
{
textBox2.Text += textBox1.Text + Environment.NewLine;
}
lxXTaCoXxl 26 Posting Whiz in Training

You can use a timer. Put a button on your form and trigger the button_click event for it. Create a timer and trigger the timer_tick event. In the button_click event start the timer. In the timer_tick event use compound assignment operator += to assign and add the text from one text box to the other.

private void Button_Click(object sender, EventArgs e)
{
timer1.Start();
}

private void Timer_Tick(object sender, EventArgs e)
{
textBox2.Text += textBox1.Text;
}

To add a new line each time on top of the text, just add + Environment.NewLine to the end of the statement. But unless you're using a richtextbox make sure you set the Multiline property of your textbox to true.

lxXTaCoXxl 26 Posting Whiz in Training

Never give up a search for anything friend. I don't know anything about them and haven't heard of them. However I'm sure we can both wait around for some smarter people to get online and tell us all about them. For I am interested in them as well now. :)

lxXTaCoXxl 26 Posting Whiz in Training

You can use the CharacterCasing property of the text box control.

private void upperCaseButton_CheckedChanged(object sender, EventArgs e)
        {
            string userText;

            if (userText == "")
                MessageBox.Show("Please enter some text");
            else
                inputTextBox.CharacterCasing = CharacterCasing.Upper;

            userText = inputTextBox.Text;
        }

It's an enum with 3 elements:

Upper
Lower
Normal

public enum CharacterCasing
{
Normal,
Upper,
Lower
}

Your welcome. :)

lxXTaCoXxl 26 Posting Whiz in Training

The reason for the null reference is that it's on a button click event, the document doesn't have the required time to load before you're accessing it; therefore the document doesn't exist yet, it's just a null value. Try putting the snippet into the web browser's Document Completed event. It will allow the document to load before you access your API. Below is an example:

// Put this into the constructor for your form.
this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted);

	// Put this anywhere in the source.
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            try
            {
                string doc;
                doc = webBrowser1.Document.Body.OuterText;


                if (doc != "Invalid Arguments !")
                {
                    //DO something
                }

            }
            catch (Exception k)
            {
                MessageBox.Show(k.ToString(), "Error");

            }
        }
lxXTaCoXxl 26 Posting Whiz in Training

So yes, it's the right side that is throwing the exception. You said that the second time it works just fine every time? That would mean it's logic related that's causing it. Probably something to do with something handling the document before you try to send it to the string. Do you have an instant messenger?

lxXTaCoXxl 26 Posting Whiz in Training

Okay, well it definitely sounds like the right side is throwing the exception. Do me a favor, purposely throw the exception, then take two screen shots of your compiler. Once with your mouse hovered over the doc variable so I can see it's value, and the second over the words OuterText so I can see the value there. It sounds to me like OuterText is returning null or doc is already null and needs to be initialized.

lxXTaCoXxl 26 Posting Whiz in Training

try setting doc to String.Empty or = ""; and see if that helps. Which line specifically in that gives you the error?

lxXTaCoXxl 26 Posting Whiz in Training

Stream writer I believe allows you to write to a specified path, however whether or not that folder requires administrator permissions I have no idea.

lxXTaCoXxl 26 Posting Whiz in Training

First fill the box with new lines:

// I'm just using 50 lines as an example.
public void FillBoxWithLines()
{
for (int i = 0; i < 50; i++)
richTextBox1.Text += Environment.NewLine;
}

Next you can use .SelectionStart to choose a line (you can specify lines using a numeric up down control or something of that nature) for my example I'll be using a numeric up down.

public int SelectedLine {get; private set;}

// numericUpDown.ValueChanged event
public void SelectLine(object sender, EventArgs e)
{
this.SelectedLine = Convert.ToInt32(numericUpDown1.Value);
}

Now that you've selected a line with numeric up down or other control, use your .SelectionStart value for the first run.

public void TypeToLine()
{
richTextBox1.SelectionStart = SelectedLine;
}

Next you can use an array that will store which lines have been written to. to ensure your place in the text.

public bool[] WrittenLines = new bool[65535];

There's a little more to it, but this should help you out. Every line after the first requires math to determine the difference in text length so that you know which lines are empty and which are not. The selection start places you at the index specified within the text length. So I'd write a method using the TextChanged event to do the math on how many characters have been added to the textbox after the lines were added, and to which line they were added.

lxXTaCoXxl 26 Posting Whiz in Training

I believe doubles already have the ability to support decimals.

lxXTaCoXxl 26 Posting Whiz in Training

Simplest way is to set the image properties to stretch it will automatically scale it to fit the form completely.

this.BackgroundImageLayout = ImageLayout.Stretch;

You're very welcome. :D

lxXTaCoXxl 26 Posting Whiz in Training

Look at you and your fancy algorithm. :D

lxXTaCoXxl 26 Posting Whiz in Training

If there is a vertical scroll bar in the text box it will appear at start when the application starts, due to the multi-line write. However, I believe richTextBox automatically has both set up automatically. I'm still not understanding what else he/she is looking for out of this though.

lxXTaCoXxl 26 Posting Whiz in Training

If you're just checking to see if the vertical scroll bar is enabled then you can tell the textbox to write multiple lines of text. Like:

void appLaunch()
{
richTextBox1.Text = "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "" + Environment.NewLine + "";
}

void timer3000ms()
{
richTextBox1.Text = "";
}

That will force around 15 lines of blank text into the text box, then with the timer, 3 seconds later it will erase the entire text box. Hope it helps. Wasn't too sure on what you're asking.