Jump to content

C# Console Application (BattleShip)

- - - - -

  • Please log in to reply
7 replies to this topic

#1
Combinu

Combinu

    Newbie

  • Members
  • Pip
  • 9 posts
Hi to all around here its nice to be a part of a programming community!

I am at an engineering course which a unit includes C# programming.
I do program in GUI but i have a small project to do with the windows console.

This project is a simple battleship game between a user and the PC, it does not have to be professional as coding but it has to meet certain requirements.

Which one of the is AI or maybe is the toughest part of them all.
AI is artificial intelligence or more over intelligent shooting.
This AI is that when the PC hits a ship it has to find the other sides (if it is not a 1 block ship) for example if there is a vertical 4 block ship and it hits the second block there must be an algorithm that finds the 1st, 3rd and 4th block of the ship before generating another location.

With this post here attached there is the full coding of my game so far. It has everything but not AI.

Quote

I am using:
C# console application
Visual Studio 2005
Microsoft Visual C# 2005

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727 SP2

Installed Edition: Professional

Microsoft Visual Basic 2005 77626-009-0000007-41895
Microsoft Visual Basic 2005

Microsoft Visual C# 2005 77626-009-0000007-41895
Microsoft Visual C# 2005

Microsoft Visual C++ 2005 77626-009-0000007-41895
Microsoft Visual C++ 2005

Microsoft Visual J# 2005 77626-009-0000007-41895
Microsoft Visual J# 2005

Microsoft Visual Web Developer 2005 77626-009-0000007-41895
Microsoft Visual Web Developer 2005

Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005


Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB925674)
This Security Update is for Microsoft Visual Studio 2005 Professional Edition - ENU. \n
If you later install a more recent service pack, this Security Update will be uninstalled automatically. \n
For more information, visit MS06-073: Vulnerability in Visual Studio 2005 could allow remote code execution

Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU (KB937060)
This Security Update is for Microsoft Visual Studio 2005 Professional Edition - ENU.
If you later install a more recent service pack, this Security Update will be uninstalled automatically.
For more information, visit Description of the security update for the Microsoft Visual Studio 2005 development platform

Can anyone please try to help me out with this i have to do it in a separate function so i am searching a full coded function of at least the algorithm on how i can make this work out.

THANKS VERY MUCH IN ADVANCE and if there is any answer out there i need it ASAP!
Thanks again!
Combinu

Attached Files


Edited by Combinu, 27 December 2010 - 01:14 PM.
Didn't write my exact compiler name and version!


#2
Generic

Generic

    Newbie

  • Members
  • PipPip
  • 26 posts
Shoot random open(not already shot at) position
if hit get all adjacent panels
shoot all adjacent panels and if one is a hit continue moving in that direction until its a miss then continue checking all other adjacent panels and repeat

#3
Combinu

Combinu

    Newbie

  • Members
  • Pip
  • 9 posts
yes i already figured something like that but my problem is how am i going to integrate it with the current pc_shoot funcion and creating a new function with this algorithm

#4
Generic

Generic

    Newbie

  • Members
  • PipPip
  • 26 posts

Combinu said:

yes i already figured something like that but my problem is how am i going to integrate it with the current pc_shoot funcion and creating a new function with this algorithm
        static List<int> xPositions = new List<int>();
        static List<int> yPositions = new List<int>();
        static void pc_shoot()
        {
            int xshoot, yshoot;
            bool hit = false;

                xshoot = rnumber(12);
                yshoot = rnumber(12);
            if (xPositions.Count > 0 && yPositions.Count > 0)
            {
                xshoot = xPositions[0];
                yshoot = yPositions[0];
                xPositions.Remove(0);
                yPositions.Remove(0);
            }

                if (player[xshoot, yshoot] == 0)
                {
                    player[xshoot, yshoot] = 10;
                }
                else if (player[xshoot, yshoot] == 1)
                {
                    player[xshoot, yshoot] = 11;
                    xPositions.Add(xshoot + 1);
                    xPositions.Add(xshoot - 1);
                    xPositions.Add(xshoot + 1);
                    xPositions.Add(xshoot - 1);

                    yPositions.Add(yshoot + 1);
                    yPositions.Add(yshoot - 1);
                    yPositions.Add(yshoot - 1);
                    yPositions.Add(yshoot + 1);
                    pchit++;
                    hit = true;
                }
            }
Something like that, I had to rework your code but it was kind of hard to read.
The code may or may not work, you'd have to change it so it'll work for you I haven't used C# in a while.

#5
Combinu

Combinu

    Newbie

  • Members
  • Pip
  • 9 posts
I have written this code you gave me but its not working i dont know why. I havent used codes like
.count and .add
if you can explain it a bit i can manage to edit it and perhaps find the problem.

The problem is this when it hits, it shoots again but in diagonal i.e. if it is hits in the box 3x3 it then shoots in 4x4 and stops shooting!!

This is the code of the whole program as the edit from you!

using System;
using System.Collections.Generic;
using System.Text;

namespace School_Projects_C_Sharp
{
    class battle_ship_assignment
    {
        static List<int> xPositions = new List<int>();
        static List<int> yPositions = new List<int>();
        static public Random generator = new Random();
        static public int[,] player = new int[12, 12];
        static public int[,] comp = new int[12, 12];
        static public string[] numbers = new string[13] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" };
        static public string[] upper = new string[12] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" };
        static public string[] lowwer = new string[12] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" };
        static public int pchit;
        static public int playerhit;
        static public int pcshoot;
        static public int playershoot;
        static public bool kp = false;
        static public string name;

        static void Main(string[] args)
        {
            bool winner = false;

            Console.WriteLine("Enter your name");
            name = Console.ReadLine();
            comp_ships();
            display();
            player_ships();
            do
            {
                pc_shoot();
                player_shoot();

                if ((pchit == 20) || (playerhit == 20))
                {
                    winner = true;
                }
            } while (winner == false);

            if (pchit == 20) Console.WriteLine("Computer Wins");
            else Console.WriteLine("Player Wins");
        }
        static void display()
        {

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" A B C D E F G H I J K L                 A B C D E F G H I J K L");
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(" -----------------------                 -----------------------");

            for (int x = 0; x < 12; x++)
            {
                for (int y = 0; y < 12; y++)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.Write("|");
                    Console.ForegroundColor = ConsoleColor.Green;
                    if (player[x, y] == 0) Console.Write(" ");
                    else if (player[x, y] == 1) Console.Write(Convert.ToChar(30));
                    else if (player[x, y] == 10) Console.Write(Convert.ToChar(15));
                    else Console.Write(Convert.ToChar(21));
                }
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("|");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write("\t" + (x + 1) + "\t");

                for (int y = 0; y < 12; y++)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.Write("|");
                    Console.ForegroundColor = ConsoleColor.Green;
                    if (comp[x, y] == 0) Console.Write(" ");
                    else if (comp[x, y] == 1) Console.Write(" ");
                    else if (comp[x, y] == 10) Console.Write(Convert.ToChar(15));
                    else Console.Write(Convert.ToChar(2));
                }
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("|");

                Console.Write("\n");
                Console.WriteLine("------------------------                 -----------------------");
            }

            Console.WriteLine("Name: " + name + "\t\t\t\t\t PC");
            Console.WriteLine("Hits: " + playerhit + "\t\t\t\t\t Hits: " + pchit);
            Console.WriteLine("Shoots: " + playershoot + "\t\t\t\t Shoots: " + pcshoot + "\n\n"); 
        }
        static void comp_ships()
        {

            int co1, co2;

            //2 submarines


            for (int i = 0; i < 2; i++)
            {

                co1 = rnumber(12);

                co2 = rnumber(12);


                if (comp[co1, co2] == 0)
                {
                    comp[co1, co2] = 1;

                }

                else i--;

            }

            // 3 - 6 ships

            for (int counter = 3; counter < 7; counter++)
            {

                co1 = rnumber(12 - counter);
                co2 = rnumber(12 - counter);
                int direction = rnumber(2);
                bool ready = false;

                if (direction == 0)
                {
                    co2 = rnumber(12);

                    do
                    {
                        if ((counter == 3) && ((comp[co1, co2] == 0) && (comp[co1 + 1, co2] == 0) && (comp[co1 + 2, co2] == 0)) || (counter == 4) && ((comp[co1, co2] == 0) && (comp[co1 + 1, co2] == 0) && (comp[co1 + 2, co2] == 0) && (comp[co1 + 3, co2] == 0))
                            || (counter == 5) && ((comp[co1, co2] == 0) && (comp[co1 + 1, co2] == 0) && (comp[co1 + 2, co2] == 0) && (comp[co1 + 3, co2] == 0) && (comp[co1 + 4, co2] == 0))
                            || (counter == 6) && ((comp[co1, co2] == 0) && (comp[co1 + 1, co2] == 0) && (comp[co1 + 2, co2] == 0) && (comp[co1 + 3, co2] == 0) && (comp[co1 + 4, co2] == 0)
                            && (comp[co1 + 5, co2] == 0)))
                        {

                            for (int i = 0; i < counter; i++)
                            {
                                comp[co1 + i, co2] = 1;
                            }
                            ready = true;
                        }
                        else
                        {
                            co1 = rnumber(12 - counter);
                            co2 = rnumber(12 - counter);
                            ready = false;
                        }
                    }
                    while (ready == false);
                }

                if (direction == 1)
                {
                    co1 = rnumber(12);

                    do
                    {
                        if ((counter == 3) && ((comp[co1, co2] == 0) && (comp[co1, co2 + 1] == 0) && (comp[co1, co2 + 2] == 0)) || (counter == 4) && ((comp[co1, co2] == 0) && (comp[co1, co2 + 1] == 0) && (comp[co1, co2 + 2] == 0) && (comp[co1, co2 + 3] == 0))
                            || (counter == 5) && ((comp[co1, co2] == 0) && (comp[co1, co2 + 1] == 0) && (comp[co1, co2 + 2] == 0) && (comp[co1, co2 + 3] == 0) && (comp[co1, co2 + 4] == 0))
                            || (counter == 6) && ((comp[co1, co2] == 0) && (comp[co1, co2 + 1] == 0) && (comp[co1, co2 + 2] == 0) && (comp[co1, co2 + 3] == 0) && (comp[co1, co2 + 4] == 0) && (comp[co1, co2 + 5] == 0)))
                        {
                            for (int i = 0; i < counter; i++)
                            {
                                comp[co1, co2 + i] = 1;
                            }
                            ready = true;
                        }

                        else
                        {
                            co1 = rnumber(12 - counter);
                            co2 = rnumber(12 - counter);
                            ready = false;
                        }
                    }
                    while (ready == false);
                }
            }
        }
        static void player_ships()
        {
            int direction, position1, position2;
            string getd, getx, gety;
            bool flag1 = false, ready = false;

            for (int s = 0; s < 2; s++)
            {
                do
                {
                    do
                    {
                        Console.WriteLine("Enter horizontal position");
                        getx = Console.ReadLine();
                        getx = letpress(getx);
                    } while (kp != false);
                    position2 = hposition(getx);
                    kp = false;
                    do
                    {
                        Console.WriteLine("Enter vertical position");
                        gety = Console.ReadLine();
                        gety = numpress(gety);
                    } while (kp != false);
                    position1 = Convert.ToInt16(gety);
                    position1--;
                    kp = false;
                    
                    if ((position1 > -1) && (position1 < 12) && (position2 > -1) && (position2 < 12) && (player[position1, position2] == 0))
                    {
                        player[position1, position2] = 1;
                        flag1 = true;
                    }
                    else
                    {
                        Console.WriteLine("Invalid inputs please try again");
                        flag1 = false;
                    }
                }
                while (flag1 == false);
                flag1 = false;
                display();
            }
            //================================ fill up boat with 3
            do
            {
                do
                {
                    do
                    {
                        Console.WriteLine("1. Horizontal :: 0. Vertial");
                        getd = Console.ReadLine();
                        getd = numpress(getd);
                    } while (kp != false);
                    direction = Convert.ToInt16(getd);
                    do
                    {
                        Console.WriteLine("Enter horizontal position");
                        getx = Console.ReadLine();
                        getx = letpress(getx);
                    } while (kp != false);
                    position2 = hposition(getx);
                    kp = false;
                    do
                    {
                        Console.WriteLine("Enter vertical position");
                        gety = Console.ReadLine();
                        gety = numpress(gety);
                    } while (kp != false);
                    position1 = Convert.ToInt16(gety);
                    position1--;
                    kp = false;
                    if (((direction == 1) && (position1 > -1) && (position1 < 10) && (position2 > -1) && (position2 < 10))
                        || ((direction == 0) && (position1 > -1) && (position1 < 10) && (position2 > -1) && (position2 < 10)))
                        flag1 = true;
                    else
                        Console.WriteLine("Invalid inputs please try again");
                } while (flag1 == false);
                if (direction == 0)
                {
                    if ((player[position1, position2] == 0) && (player[position1 + 1, position2] == 0)
                        && (player[position1 + 2, position2] == 0))
                    {
                        for (int fill = 0; fill < 3; fill++)
                        {
                            player[position1 + fill, position2] = 1;
                        }
                        ready = true;
                    }
                    else Console.WriteLine("Position contains a ship");
                }
                if (direction == 1)
                {
                    if ((player[position1, position2] == 0) && (player[position1, position2 + 1] == 0)
                        && (player[position1, position2 + 2] == 0))
                    {
                        for (int fill = 0; fill < 3; fill++)
                        {
                            player[position1, position2 + fill] = 1;
                        }
                        ready = true;
                    }
                    else Console.WriteLine("Position contains a ship");
                }
            }
            while (ready == false);
            display();

            ready = false;


        
            //================================ fill up boat with 4
            do
            {
                do
                {
                    do
                    {
                        Console.WriteLine("1. Horizontal :: 0. Vertial");
                        getd = Console.ReadLine();
                        getd = numpress(getd);
                    } while (kp != false);
                    direction = Convert.ToInt16(getd);
                    do
                    {
                        Console.WriteLine("Enter horizontal position");
                        getx = Console.ReadLine();
                        getx = letpress(getx);
                    } while (kp != false);
                    position2 = hposition(getx);
                    kp = false;
                    do
                    {
                        Console.WriteLine("Enter vertical position");
                        gety = Console.ReadLine();
                        gety = numpress(gety);
                    } while (kp != false);
                    position1 = Convert.ToInt16(gety);
                    position1--;
                    kp = false;
                    if (((direction == 1) && (position1 > -1) && (position1 < 12) && (position2 > -1) && (position2 < 9))
                       || ((direction == 0) && (position1 > -1) && (position1 < 9) && (position2 > -1) && (position2 < 12)))
                        flag1 = true;
                    else
                    {
                        Console.WriteLine("Invalid inputs please try again");
                        flag1 = false;
                    }


                } while (flag1 == false);

                if (direction == 0)
                {
                    if ((player[position1, position2] == 0) && (player[(position1 + 1), position2] == 0)
                        && (player[(position1 + 2), position2] == 0) && (player[(position1 + 3), position2] == 0))
                    {
                        for (int fill = 0; fill < 4; fill++)
                        {
                            player[position1 + fill, position2] = 1;
                        }
                        ready = true;
                    }
                    else
                        Console.WriteLine("Position contains a ship");
                }

                if (direction == 1)
                {
                    if ((player[position1, position2] == 0) && (player[position1, position2 + 1] == 0)
                        && (player[position1, position2 + 2] == 0) && (player[position1, position2 + 3] == 0))
                    {
                        for (int fill = 0; fill < 4; fill++)
                        {
                            player[position1, position2 + fill] = 1;
                        }
                        ready = true;
                    }
                    else Console.WriteLine("Position contains a ship");
                }
            }
            while (ready == false);
            display();

            ready = false;

            
            //===================================== 5 box boat

            do
            {
                do
                {
                    do
                    {
                        Console.WriteLine("1. Horizontal :: 0. Vertial");
                        getd = Console.ReadLine();
                        getd = numpress(getd);
                    } while (kp != false);
                    direction = Convert.ToInt16(getd);
                    do
                    {
                        Console.WriteLine("Enter horizontal position");
                        getx = Console.ReadLine();
                        getx = letpress(getx);
                    } while (kp != false);
                    position2 = hposition(getx);
                    kp = false;
                    do
                    {
                        Console.WriteLine("Enter vertical position");
                        gety = Console.ReadLine();
                        gety = numpress(gety);
                    } while (kp != false);
                    position1 = Convert.ToInt16(gety);
                    position1--;
                    kp = false;
                    if (((direction == 1) && (position1 > -1) && (position1 < 12) && (position2 > -1) && (position2 < 8))
                       || ((direction == 0) && (position1 > -1) && (position1 < 8) && (position2 > -1) && (position2 < 12)))
                        flag1 = true;
                    else
                    {
                        Console.WriteLine("Invalid inputs please try again");
                        flag1 = false;
                    }

                } while (flag1 == false);

                if (direction == 0)
                {
                    if ((player[position1, position2] == 0) && (player[(position1 + 1), position2] == 0)
                        && (player[(position1 + 2), position2] == 0) && (player[(position1 + 3), position2] == 0) && (player[(position1 + 4), position2] == 0))
                    {
                        for (int fill = 0; fill < 5; fill++)
                        {
                            player[position1 + fill, position2] = 1;
                        }
                        ready = true;
                    }
                    else
                        Console.WriteLine("Position contains a ship");
                }

                if (direction == 1)
                {
                    if ((player[position1, position2] == 0) && (player[position1, position2 + 1] == 0)
                        && (player[position1, position2 + 2] == 0) && (player[position1, position2 + 3] == 0) && (player[position1, position2 + 4] == 0))
                    {
                        for (int fill = 0; fill < 5; fill++)
                        {
                            player[position1, position2 + fill] = 1;
                        }
                        ready = true;
                    }
                    else Console.WriteLine("Position contains a ship");
                }
            }
            while (ready == false);
            display();

            ready = false;

            //===================================== 6 box boat

            do
            {
                do
                {
                    do
                    {
                        Console.WriteLine("1. Horizontal :: 0. Vertial");
                        getd = Console.ReadLine();
                        getd = numpress(getd);
                    } while (kp != false);
                    direction = Convert.ToInt16(getd);
                    do
                    {
                        Console.WriteLine("Enter horizontal position");
                        getx = Console.ReadLine();
                        getx = letpress(getx);
                    } while (kp != false);
                    position2 = hposition(getx);
                    kp = false;
                    do
                    {
                        Console.WriteLine("Enter vertical position");
                        gety = Console.ReadLine();
                        gety = numpress(gety);
                    } while (kp != false);
                    position1 = Convert.ToInt16(gety);
                    position1--;
                    kp = false;
                    if (((direction == 1) && (position1 > -1) && (position1 < 12) && (position2 > -1) && (position2 < 7))
                       || ((direction == 0) && (position1 > -1) && (position1 < 7) && (position2 > -1) && (position2 < 12)))
                        flag1 = true;
                    else
                    {
                        Console.WriteLine("Invalid inputs please try again");
                        flag1 = false;
                    }

                } while (flag1 == false);

                if (direction == 0)
                {
                    if ((player[position1, position2] == 0) && (player[(position1 + 1), position2] == 0)
                        && (player[(position1 + 2), position2] == 0) && (player[(position1 + 3), position2] == 0) && (player[(position1 + 4), position2] == 0) && (player[(position1 + 5), position2] == 0))
                    {
                        for (int fill = 0; fill < 6; fill++)
                        {
                            player[position1 + fill, position2] = 1;
                        }
                        ready = true;
                    }
                    else
                        Console.WriteLine("Position contains a ship");
                }

                if (direction == 1)
                {
                    if ((player[position1, position2] == 0) && (player[position1, position2 + 1] == 0)
                        && (player[position1, position2 + 2] == 0) && (player[position1, position2 + 3] == 0) && (player[position1, position2 + 4] == 0) && (player[position1, position2 + 5] == 0))
                    {
                        for (int fill = 0; fill < 6; fill++)
                        {
                            player[position1, position2 + fill] = 1;
                        }
                        ready = true;
                    }
                    else Console.WriteLine("Position contains a ship");
                }
            }
            while (ready == false);
            display();

            ready = false;

        }
        /*static void pc_shoot()
        {
            int xshoot, yshoot;
            bool hit = false;

            do
            {
                xshoot = rnumber(12);
                yshoot = rnumber(12);

                if ((player[xshoot, yshoot] == 0) || (player[xshoot, yshoot] == 1))
                {
                    if (player[xshoot, yshoot] == 0)
                    {
                        player[xshoot, yshoot] = 10;
                    }
                    else
                    {
                        player[xshoot, yshoot] = 11;
                        pchit++;
                    }

                    hit = true;
                }
            } while (hit == false);
            pcshoot++;
            display();
        }*/
        static void pc_shoot()
        {
            int xshoot, yshoot;
            bool hit = false;

            xshoot = rnumber(12);
            yshoot = rnumber(12);
            if (xPositions.Count > 0 && yPositions.Count > 0)
            {
                xshoot = xPositions[0];
                yshoot = yPositions[0];
                xPositions.Remove(0);
                yPositions.Remove(0);
            }

            if (player[xshoot, yshoot] == 0)
            {
                player[xshoot, yshoot] = 10;
            }
            else if (player[xshoot, yshoot] == 1)
            {
                player[xshoot, yshoot] = 11;
                xPositions.Add(xshoot + 1);
                xPositions.Add(xshoot - 1);
                xPositions.Add(xshoot + 1);
                xPositions.Add(xshoot - 1);

                yPositions.Add(yshoot + 1);
                yPositions.Add(yshoot - 1);
                yPositions.Add(yshoot - 1);
                yPositions.Add(yshoot + 1);
                pchit++;
                hit = true;
            }
            display();
        }
        static void player_shoot()
        {
            int xshoot, yshoot;
            string getx, gety;
            bool hit = false;
            bool planex = false;
            bool planey = false;

            do
            {
                do
                {
                    Console.Write("Enter X Coordinate\n");
                    getx = Console.ReadLine();
                    //getx = keypress(getx);
                    yshoot = hposition(getx);
                    if ((yshoot > -1) && (yshoot < 12))
                    {
                        planex = true;
                    }
                    else Console.Write("\nInvalid Input\n");
                } while (planex == false);
                do
                {
                    Console.Write("Enter Y Coordinate\n");
                    gety = Console.ReadLine();
                    xshoot = Convert.ToInt16(gety);
                    xshoot--;
                    if ((xshoot > -1) && (xshoot < 12))
                    {
                        planey = true;
                    }
                    else Console.Write("\nInvalid Input\n");
                } while (planey == false);


                if ((comp[xshoot, yshoot] == 0) || (comp[xshoot, yshoot] == 1))
                {
                    if (comp[xshoot, yshoot] == 0)
                    {
                        comp[xshoot, yshoot] = 10;
                    }
                    else
                    {
                        comp[xshoot, yshoot] = 11;
                        playerhit++;
                    }

                    hit = true;
                }
                else Console.Write("\nAlready Contains a hit.\n");
            } while (hit == false);
            playershoot++;
            display();
        }
        static int rnumber(int number)
        {
            int z;

            z = (int)(generator.NextDouble() * number);
            return (z);
        }
        static int hposition(string hchar)
        {
            int hpos;
            int x = System.Convert.ToInt16(hchar[0]);

            switch (x)
            {
                case 65:
                case 97:
                    hpos = 0;
                    break;
                case 66:
                case 98:
                    hpos = 1;
                    break;
                case 67:
                case 99:
                    hpos = 2;
                    break;
                case 68:
                case 100:
                    hpos = 3;
                    break;
                case 69:
                case 101:
                    hpos = 4;
                    break;
                case 70:
                case 102:
                    hpos = 5;
                    break;
                case 71:
                case 103:
                    hpos = 6;
                    break;
                case 72:
                case 104:
                    hpos = 7;
                    break;
                case 73:
                case 105:
                    hpos = 8;
                    break;
                case 74:
                case 106:
                    hpos = 9;
                    break;
                case 75:
                case 107:
                    hpos = 10;
                    break;
                case 76:
                case 108:
                    hpos = 11;
                    break;
                default:
                    hpos = 20;
                    break;
            }
            return hpos;
        }
        static string numpress(string key)
        {
            for (int z = 0; z < 13; z++)
            {
                if (key == numbers[z])
                {
                    return key;
                    kp = true;
                    break;
                }
            }
            kp = false;

            return "200";

        }
        static string letpress(string key)
        {
            for (int z = 0; z < 12; z++)
            {
                if (key == lowwer[z])
                {
                    return key;
                    kp = true;
                    break;
                }
                if (key == upper[z])
                {
                    return key;
                    kp = true;
                    break;
                }

            }
            kp = false;

            return "Z";

        }
    }
}
           





Thanks for you help i really appreciated your help thanks!!!

#6
Generic

Generic

    Newbie

  • Members
  • PipPip
  • 26 posts
List(T) Class (System.Collections.Generic)

Change the Removes to RemoveAt.

#7
Combinu

Combinu

    Newbie

  • Members
  • Pip
  • 9 posts
I made the change you told me but still having the same problem :( i am trying to figure out what type of code you gave me from the link of the previous post but still cant seem to do any process :(

Btw.. Happy new year :)

#8
you2030

you2030

    Newbie

  • Members
  • Pip
  • 1 posts
To set up the project in Microsoft Visual Studio .NET 2005

1-Open Microsoft Visual Studio .NET 2005 and, from the File menu, choose New | Project. The New Project dialog box appears.
2-In the Project types pane, choose Visual C# and then choose Windows.
3-In the Templates pane, choose Console Application.
4-Type the name of the project, ConsoleSampleWebSearch, in the Name text box and click OK. Visual Studio creates a new project.
5-In the Solution Explorer, right-click References and, from the pop-up menu, select Add Web Reference.
6-Type the following address in the URL text box: http://soap.search.m...vices.asmx?wsdl.
7-Click Go.
8-In the Web reference name text box, type LiveSearch and click Add Reference.

To add the source code to the project

1-Replace the source code in the file Program.cs with the source code in the Example section. To do this:
a-Click Copy Code to place the code in the Windows Clipboard.
b-Open Program.cs from the Solution Explorer, place your cursor anywhere in the file, and press Ctrl + A.
d-Press Ctrl + V to paste the code into the Visual Studio source file, overwriting the template-generated code.

2-Search for and replace the text YOUR_APP_ID_GOES_HERE with the AppID you generated from the Developer Provisioning System.
3-Press F5 to run the application in Debug mode.

Requirements

- Microsoft Visual Studio .NET 2005 or Microsoft Visual C# .NET 2005.
- Internet connection.
- Application ID. (See Getting Started with the Live Search API for more information on obtaining an AppID for use with the Live Search Web Service.)

Demonstrates

A basic Web search using the keywords live search and default input parameters.
-------------------------------------
online pharmacy UK | buy Marvelon online uk | buy proviron online uk | buy Skinoren online uk | buy Elidel cream online uk




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users