1

I'm having a slight issue with my program. I'm a first year student and am trying to make a program on flight reservation.

if (txtSeat.Text == "1")
{
   btnRowOneSeatOne.BackColor = Color.Red;
   goodMessage += "You Selected Row One and Seat One";
}

So, this basically goes down for all 15 seats in the same manner. I have a textbox and if you type numbers from 1-15 the seat will button turn red.

I also did pretty much the same thing in removing the customer. As followed

This was in the remove button handle

if (txtRemove.Text == "1")
{
       btnRowOneSeatOne.BackColor = Color.Black;
}

I haven't started on an array yet. Basically for that I have a text box once the number is enter it should store it in the array.

I believe this should be the coding

seatNum = int.Parse(txtSeat.Text);
bool availability = false;

for (int s = 0; s < seats.Length; s++)
{
    seats[s] = seatNum
    availability = true;
    break;
}
if (availability == true)
{
}

I believe this should store the seat in array. I've tried many different ways, but couldn't seem to find away. This is an assignment for a class FYI.

4
  • not sure what you want. Commented Dec 6, 2013 at 5:28
  • I apologize for not explaining this well. What I need is two things. I'm trying to store number data from a textbook into the array, which is the last coding I have in my main post, but I'm getting a problems with that code. The other thing was that once the array is full I would like to add it to a listbox, which I'm not sure on how to do. Commented Dec 6, 2013 at 5:40
  • How does the input data look like in your textbox? a comma-separated string? or any other pattern? You should make it clear on that. Commented Dec 6, 2013 at 5:42
  • Thank you four response again. I'll try being as clear as possible. I have 15 buttons and each button has a number assigned to it from 1-15. When you enter one of the numbers into the text box and hit add to flight button the button backcolor changes to red and with a message box popping up informing passenger has been added. I basically want that text box in which I enter the number in to store all that data into the array and if you try selecting the number again I want to add the passenger into the a listbox. Commented Dec 6, 2013 at 6:00

1 Answer 1

1
          int seatnum = int.Parse(textBox1.Text);
         Seat = new int[15];
        if (textBox1.Text != "")
        {
            Seat[seatnum - 1] = seatnum;
        }
        for (int i = 0; i < 15; i++)
        {
            if (Seat[i] != 0)
            {
                listBox1.Items.Add(textBox1.Text);
            }
        }
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the response. I tried this code and it works, but it isn't what I'm actually looking for. When I put this code in right when I hit my button to add it puts the number in the list. What I'm looking for is first I need to make sure that whatever i type in the text box (numbers) it adds to my array and once I get that I'd like to add people to the list once the array is full.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.