Mike Askew 131 Veteran Poster Featured Poster

Please make a new thread for your issue instead of hijacking a two year old one.

The issue will be that you do not return a value in every possible outcome of the method you are in.

For example if an if else statement you must return values in both sections of it

public bool DemoMethod(string Input)
{
    if (Input == "Hello")
    {
        return true;
    }
    else
    {
        return false;
    }
}

or another common one would be

public bool DemoMethod(string Input)
{
    if (Input == "Hello")
    {
        return true;
    }
    // Not having a return call here will give the error you see as you do not provide a return path if the code does not enter the if loop
}

Would need to see the full code block to identify the missing line though

Mike Askew 131 Veteran Poster Featured Poster

I would have come up with the same as Fenrir() from looking at your code. The above is the correct code for your commented out section around a confirmation.

He just has omited code to save the record.

Mike Askew 131 Veteran Poster Featured Poster

A good attempt. Some improvements can be made which should help you progress your programming knowledge.

Firstly when converting anything from one type to another we need some form of exception handling in place. Otherwise if I entered a letter your program would fall over.

Here we can make use of the bool int32.TryParse(string, out int); function to check if the string entered into the console can be converted to an integer.

Using the following code block we can do this:

Console.Write("Enter First Value: ");
while (!Int32.TryParse(Console.ReadLine(), out ValueOne))
{
    Console.WriteLine("Please enter a numeric value!");
    Console.WriteLine();
    Console.Write("Enter First Value: ");
}

We get the first value off the user. The .TryParse then attempts to convert the Console.ReadLine() to an integer, with the out parameter being set to the value of the successful convert.

This method also returns a bool depending on successs or failure. Therefore I can use this to control the while loop that enables multiple entries of the value until it successfully converts to an integer.

One other thing I picked up on was your use of the newline character at the end of your Console.Write() calls. There is infact a method to do this for you called Console.WriteLine() which will automatically drop to a new line at the end of its sentence.

For example:

Console.WriteLine("Before swap ValueOne: {0}; ValueTwo: {1}", ValueOne, ValueTwo);

Here would be the full code for what you did including error handling and the tidy up of Console.Write():

static …
ddanbe commented: Fine explanation. +15
Mike Askew 131 Veteran Poster Featured Poster

The Hobbit - Desolation Of Smaug.

Would recommend.

Mike Askew 131 Veteran Poster Featured Poster

There is a you can use preceding-sibling to do this.

Additional Info

Mike Askew 131 Veteran Poster Featured Poster

Had a feeling it might, but the laws do not

Mike Askew 131 Veteran Poster Featured Poster

Lol, i never use it ;D I am too lazy to click the green check and edit ;D

I guessed, it's quite obvious.

<M/> commented: lol +0
Mike Askew 131 Veteran Poster Featured Poster

Just got this in an email also, quite interesting.

Mike Askew 131 Veteran Poster Featured Poster

Perhaps we all should stop driving?
Driving a car pollutes the air with cancerogenic substances and fine dust, which in the end will kill us all.

I rather enjoy driving, I pay the tax for it, so will continue to do it.

Most effective solution would be to pass a law implementing a new technology to test before starting the car.

Obviously a tad impracticle but would work.

Mike Askew 131 Veteran Poster Featured Poster

Dani has already made that, it is on your toolbar (the green checkmark)

Well it didn't fix yours, I presume it is spelling not grammar :)

Reverend Jim commented: Hah! +0
Mike Askew 131 Veteran Poster Featured Poster

Had a feeling you would know a cleaner implementation

Mike Askew 131 Veteran Poster Featured Poster

UK, shit, enough said.

<M/> commented: lol +0
Mike Askew 131 Veteran Poster Featured Poster

Don't see the point, would most likely be a drain on the servers and most people would do dev in an IDE.

Maybe we should get an automatic grammar fixing device also :D

Mike Askew 131 Veteran Poster Featured Poster

Modify the constructor for the search form to take a parameter to tell it which tab to open and then use a switch block to handle the param value and open the right tab?

Quite a messy way to do it but would work.

Mike Askew 131 Veteran Poster Featured Poster

At least he isn't creating bogus accounts and endorsing himself. That would be pretty low.

Or posting random questions in the Geeks Lounge to boost their ego, forgot that one too!

<M/> commented: Ikr... +0
Mike Askew 131 Veteran Poster Featured Poster

Of course we cannot forget to thank the teacher or whomever of hxn xfir for providing us, bored at work, with this now fun little competition.

I need to tidy my code up a bit and rethink my logic clearly!

Mike Askew 131 Veteran Poster Featured Poster

Haha god damn my method is looking extremely bad now xD

Mine is based off a loop and identifying the last number added to the sequence, was bored and had nothing to do at work :p

static void Main(string[] args)
        {
            // Works up to 10
            int NumberOfNumbersToAdd = 5;

            #region Don't need to change these
            string Output = "";
            int Padding = (NumberOfNumbersToAdd * 2) - 1;
            #endregion

            if (NumberOfNumbersToAdd * 2 >= 20)
                Padding++;

            for (int i = 1; i != NumberOfNumbersToAdd; i++)
            {
                if (Output.Length == 0)
                {
                    Output = "1";
                    Console.WriteLine(Output.PadLeft(Padding, ' '));
                }

                if (Output.Length > 0)
                {
                    int CurNum = Convert.ToInt32(Output[Output.Length / 2].ToString());
                    int NewNum = CurNum + 1;
                    Output = string.Concat(Output.Substring(0, Output.LastIndexOf(CurNum.ToString()) + 1), NewNum, Output.Substring(Output.LastIndexOf(CurNum.ToString())));
                    Console.WriteLine(Output.PadLeft(Padding, ' '));
                }
            }

            for (int i = 1; i != NumberOfNumbersToAdd; i++)
            {
                int CurNum = Convert.ToInt32(Output[Output.Length / 2].ToString());
                Output = string.Concat(Output.Substring(0, Output.LastIndexOf(CurNum.ToString()) - 1), Output.Substring(Output.LastIndexOf(CurNum.ToString()) + 1));
                Console.WriteLine(Output.PadLeft(Padding, ' '));
            }

            Console.ReadLine();
        }
Mike Askew 131 Veteran Poster Featured Poster

Well I've just done it for fun, was interesting. My code is probably messy but oh well!

Show us what you have done and we can help.

ddanbe commented: naughty! ;) +15
Mike Askew 131 Veteran Poster Featured Poster

http://www.daniweb.com/software-development/csharp/threads/437362/getting-started-with-c-the-list

The HomeAndLearn link covers database connections if memory serves correctly.

Mike Askew 131 Veteran Poster Featured Poster

Wonderful news!

Mike Askew 131 Veteran Poster Featured Poster

@Mike Askew you've got a Z4 and you're not even 25! that's good going that is!.

Aha thanks :) Looking to get a V6 version on January possibly, else delay slightly and buy a Z4M.

Was also exploring the possibilites of the V6 3 series :/

Mike Askew 131 Veteran Poster Featured Poster

It is worth noting you never shut connections to the database, close the connection after each call, it could be causing a hidden error (though unlikely as it would be an exception)

Mike Askew 131 Veteran Poster Featured Poster

You will attract alot more interest in helping if you show us what you have so far and what you have tried.

Mike Askew 131 Veteran Poster Featured Poster

I second the opinion that it is a wannabe kid :3

Mike Askew 131 Veteran Poster Featured Poster

My corporate emails still use <img> tags and they show fine in my Outlook 2013.

Mike Askew 131 Veteran Poster Featured Poster

I can't replicate your issue.

Works fine with:

            Console.Write("Enter your text: ");
            string Input = Console.ReadLine();
            Input = Input.ToLower();
            string Result = Input.Replace("remove", "");
            Console.WriteLine("Edited text: " + Result);
            Console.ReadLine();

Sentence: "There is one word to remove in this sentence"

Tested with "remove" and "removed", remove worked, removed didn't.

Mike Askew 131 Veteran Poster Featured Poster

BMW Z4, hit 50k miles last week, brought in January around 43k.

Mike Askew 131 Veteran Poster Featured Poster

Can you upload your solution somewhere for me to download and look at? Can't see what would cause the error by eye.

Mike Askew 131 Veteran Poster Featured Poster

Could you highlight which line the error occurs on, Tinstaafl is correct about the alternate way to change the value also though :)

I find it odd that you would get an object not initialised error in the code block you linked as it is specifically initialised on line 4 to be a new empty list.

Mike Askew 131 Veteran Poster Featured Poster

You almost had it and had the correct idea moving the list declaration outside of the switch function, the small details are what caught you out though!

string board = "1";

// Here we declare an empty list called icons
List<string> icons = new List<string>();

switch (board)
{
    // We then re-initialise the list depending upon case
    case "1":
        icons = new List<string>() { "!", "!", "N", "N", ",", ",", "k", "k", "b", "b", "v", "v", "w", "w", "z", "z" };
            break;
    case "2":
        icons = new List<string>() { [Different String Set Here] };
            break;  
}

In the above code we declare the icon list once outside of the switch statement;

Within each case statement we simply re-instanciate the list with a new value set instead of fully re-defining it each time which was the original cause of the error.

Mike Askew 131 Veteran Poster Featured Poster

IIRC, calling something along the lines of this.Refresh(); after line 135 will force the form's redraw event before the thread continues and sound plays.

Mike Askew 131 Veteran Poster Featured Poster

Right so I've done some toying around this morning. Seems I misunderstood how the sound play works slightly. The .wav is played on its own thread automatically.

Mike Askew 131 Veteran Poster Featured Poster

If no one else comes up with the code I will have a toy at work tomorrow if I get time and see if I can get a rough example done

Mike Askew 131 Veteran Poster Featured Poster

The Sleep function will pause the current thread it is called on. As this is the UI thread from what I can see it will simply 'pause' the entire program for that amount of time.

You could use a background worker or second thread to handle the sound being played and then when you sleep that thread it would not impact the turning over of the cards on the main UI thread.

Mike Askew 131 Veteran Poster Featured Poster

Ok, let us know if you run into any issues.

Mike Askew 131 Veteran Poster Featured Poster

The config file would be visible to anyone with access to the server yes. That is why you encrypt the information so that it becomes secure.

It is possible to do within the C# code yes but it is not best practice and the connection string is impossible to change without recompiling the code from an IDE.

Mike Askew 131 Veteran Poster Featured Poster

http://www.connectionstrings.com/

Why is the application config unsecure in your situation? It is better practice to put the string here than inside the application so that it can be changed without re-compiling as you deploy to different environments.

See the section in this MSDN article where it discusses encrypting the application config connection string.

ddanbe commented: Good advice. +14
Mike Askew 131 Veteran Poster Featured Poster

Putting the connection string the application config file is good practice and will allow for such changes without needing a re-compile of code.

Begginnerdev commented: Yep! +9
Mike Askew 131 Veteran Poster Featured Poster

Thanks for doing so Dani :)!

Mike Askew 131 Veteran Poster Featured Poster

That is true they aren't cheap, forgot about import etc also as brought mine in the UK

Mike Askew 131 Veteran Poster Featured Poster

<input type="text" value="" style="width:100%" name="message" id="chat-message">

Adding autocomplete="off" to the above text box line would allow chat to not remember inputs and also functions fully without any other changes.

Mike Askew 131 Veteran Poster Featured Poster

100+ endorsements, of which a at least 7 in each category are from a subset of accounts that appeared about 7 months ago, endorsed him and upvoted, and then became inactive again and haven't been seen since.

Mike Askew 131 Veteran Poster Featured Poster

i have about 18 years of expirience banging tables :P only reason i dont have a drumkit at home is because of how quiet my neighborhood is , and how much the neighbors would like to keep it that way. I played guitar , until the neck bent and now tunes drop even with half-hours strumming. :(

Get an electronic drum kit, I have a Roland one and you can play through headphones when needed or an amp.

Mike Askew 131 Veteran Poster Featured Poster

Does the unknown node always have the Code="CPT" attribute and is the only node within the <SegmentX> node to contain such an attribute value?

If so you could do something along the lines of search the <SegmentX> child nodes for a node with the matching attribute.

Unfortunately I am a .Net developer so can't deliver on the PHP code front but have toyed with XML enough to try give an insight into logic you could use.

Mike Askew 131 Veteran Poster Featured Poster

The code looks a pretty embedded part of that question though including quoted parts of it in responses and a follow up question also based off further code blocks.

Deleting these would make the thread almost impossible to follow imho

Mike Askew 131 Veteran Poster Featured Poster

If only one knew how to do such aha

Mike Askew 131 Veteran Poster Featured Poster

Is it possible to stop the chat input box from remembering history? It is highly irritating :D

Tried a quick fix using autocomplete="off" in the <form> tag of the html and it worked fine in terms of turning off the autocomplete however it stopped the chat entry box from clearing on submit so feel there would be a further tweak required.

Mike Askew 131 Veteran Poster Featured Poster

My comment is UK based :)

Mike Askew 131 Veteran Poster Featured Poster

Assuming these sites are hidden in the dark corners of the internet, which they are, you would have had to have been specifically looking for it to 'stumble' apon it to then even start this debate.

My question is: why were you looking?

Mike Askew 131 Veteran Poster Featured Poster

Presume you did a fairly decent google yourself as you have a brain.. I can't find anything either, the User32.dll is required for bringing the window to front as far as I can see, can find a process using the Diagnostics.Process class or through the User32.dll though.