Results 1 to 18 of 18

Thread: very stuck on a program, need major help!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    73

    very stuck on a program, need major help!

    I have a program with 36 check boxes in a group box, 1 for each seat of an airplane. Then I have 4 more in another group box for each of the possible locations of the flight. There are 4 first class seats, 8 business class seats, and 24 economy class seats. The check boxes are changed to display as buttons. I have to use at least one multidimensional array. I set the multidimensional array to data type Checkbox, but I'm not sure if that is correct because now I can't seem to assign any values to the array. It always says it can not be converted. Also, I have to be able to assign a name to each checkbox and then also a meal (there are 4 different choices), and while the program is running there should be a tool tip when the mouse is hovered over the check box that will display the name of the passenger and which meal they chose.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    73

    Re: very stuck on a program, need major help!

    here is what I have so far. As you can see there is a lot commented out...:

    vb.Net Code:
    1. Option Strict On
    2. Option Explicit On
    3. Public Class frmMain
    4.     Private SeatingArray(8, 3) As CheckBox
    5.     Private LocationArray(3) As CheckBox
    6.  
    7.     '====================================================frmMain_Load=====================================================================
    8.     Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    9.         LocationArray(0) = cbxOH
    10.         LocationArray(1) = cbxAR
    11.         LocationArray(2) = cbxMO
    12.         LocationArray(3) = cbxOK
    13.  
    14.         Dim TicketPrice As Integer 'Holds basic ticket price.
    15.         'Set Ticket price based on location of flight.
    16.         If cbxOH.Checked Then
    17.             TicketPrice = 250
    18.         ElseIf cbxAR.Checked Then
    19.             TicketPrice = 300
    20.         ElseIf cbxMO.Checked Then
    21.             TicketPrice = 100
    22.         ElseIf cbxOK.Checked Then
    23.             TicketPrice = 400
    24.         End If
    25.  
    26.        
    27.  
    28.         'cbxOH = LocationArray(0)
    29.         'cbxAR = LocationArray(1)
    30.         'cbxMO = LocationArray(2)
    31.         'cbxOK = LocationArray(3)
    32.         'cbxSeat1 = SeatingArray(0, 0)
    33.         'cbxSeat2 = SeatingArray(0, 1)
    34.         'cbxSeat3 = SeatingArray(0, 2)
    35.         'cbxSeat4 = SeatingArray(0, 3)
    36.         'cbxSeat5 = SeatingArray(1, 0)
    37.         'cbxSeat6 = SeatingArray(1, 1)
    38.         'cbxSeat7 = SeatingArray(1, 2)
    39.         'cbxSeat8 = SeatingArray(1, 3)
    40.         'cbxSeat9 = SeatingArray(2, 0)
    41.         'cbxSeat10 = SeatingArray(2, 1)
    42.         'cbxSeat11 = SeatingArray(2, 2)
    43.         'cbxSeat12 = SeatingArray(2, 3)
    44.         'cbxSeat13 = SeatingArray(3, 0)
    45.         'cbxSeat14 = SeatingArray(3, 1)
    46.         'cbxSeat15 = SeatingArray(3, 2)
    47.         'cbxSeat16 = SeatingArray(3, 3)
    48.         'cbxSeat17 = SeatingArray(4, 0)
    49.         'cbxSeat18 = SeatingArray(4, 1)
    50.         'cbxSeat19 = SeatingArray(4, 2)
    51.         'cbxSeat20 = SeatingArray(4, 3)
    52.         'cbxSeat21 = SeatingArray(5, 0)
    53.         'cbxSeat22 = SeatingArray(5, 1)
    54.         'cbxSeat23 = SeatingArray(5, 2)
    55.         'cbxSeat24 = SeatingArray(5, 3)
    56.         'cbxSeat25 = SeatingArray(6, 0)
    57.         'cbxSeat26 = SeatingArray(6, 1)
    58.         'cbxSeat27 = SeatingArray(6, 2)
    59.         'cbxSeat28 = SeatingArray(6, 3)
    60.         'cbxSeat29 = SeatingArray(7, 0)
    61.         'cbxSeat30 = SeatingArray(7, 1)
    62.         'cbxSeat31 = SeatingArray(7, 2)
    63.         'cbxSeat32 = SeatingArray(7, 3)
    64.         'cbxSeat33 = SeatingArray(8, 0)
    65.         'cbxSeat34 = SeatingArray(8, 1)
    66.         'cbxSeat35 = SeatingArray(8, 2)
    67.         'cbxSeat36 = SeatingArray(8, 3)
    68.  
    69.  
    70.  
    71.  
    72.  
    73.         'SeatingArray(0, 0) = "Tristan Forbes, Veg"
    74.         'SeatingArray(0, 1) = "Alicia Forbes, Beef"
    75.         'SeatingArray(0, 2) = "Karen Schumacher, Fish"
    76.         'SeatingArray(0, 3) = "Dan Johnson, Fish"
    77.         'SeatingArray(1, 0) = "Will Farell, Beef"
    78.         'SeatingArray(1, 1) = "Dwayne Johnson, Chicken"
    79.         'SeatingArray(1, 2) = "Joe Jackson, Beef"
    80.         'SeatingArray(1, 3) = "Wang Chung, Fish"
    81.         'SeatingArray(2, 0) = "John Conner, Chicken"
    82.         'SeatingArray(2, 1) = "Dave Ramsey, Beef"
    83.         'SeatingArray(2, 2) = "Joseph Dredd. Beef"
    84.         'SeatingArray(2, 3) = "Snake Pliskin, Veg"
    85.         'SeatingArray(3, 0) = "Luke Skywalker, Fish"
    86.         'SeatingArray(3, 1) = "Mario Mario, Chicken"
    87.         'SeatingArray(3, 2) = "Luigi Mario, Veg"
    88.         'SeatingArray(3, 3) = "Samus Aran, Fish"
    89.         'SeatingArray(4, 0) = "Rooster Cogburn, Beef"
    90.         'SeatingArray(4, 1) = "Douglas Quid, Beef"
    91.         'SeatingArray(4, 2) = "Alex Murphy, Fish"
    92.         'SeatingArray(4, 3) = "Han Solo, Chicken"
    93.         'SeatingArray(5, 0) = "Optimus Prime, Veg"
    94.         'SeatingArray(5, 1) = "Indiana Jones, Chicken"
    95.         'SeatingArray(5, 2) = "Jackie Chan, Beef"
    96.         'SeatingArray(5, 3) = "Genghis Khan, Beef"
    97.         'SeatingArray(6, 0) = "Albert Einstein, Chicken"
    98.         'SeatingArray(6, 1) = "Steve Jobs, Veg"
    99.         'SeatingArray(6, 2) = "Robin Hood, Beef"
    100.         'SeatingArray(6, 3) = "Bruce Wayne, Fish"
    101.         'SeatingArray(7, 0) = "Clark Kent, Veg"
    102.         'SeatingArray(7, 1) = "Hal Jordan, Chicken"
    103.         'SeatingArray(7, 2) = "Diana Price, Chicken"
    104.         'SeatingArray(7, 3) = "Barry Allen, Beef"
    105.         'SeatingArray(8, 0) = "Oliver Queen, Chicken"
    106.         'SeatingArray(8, 1) = "J'onn J'onzz, Chicken"
    107.         'SeatingArray(8, 2) = "Victor Stone, Veg"
    108.         'SeatingArray(8, 3) = "Charles Xavier, Fish"
    109.         'SeatingArray(9, 0) = "Lars Ulrich, Veg"
    110.         'SeatingArray(9, 1) = "Jean Grey, Fish"
    111.         'SeatingArray(9, 2) = "Peter Parker, Beef"
    112.         'SeatingArray(9, 3) = "Bruce Banner, Beef"
    113.  
    114.  
    115.  
    116.  
    117.  
    118.     End Sub
    119. End Class

  3. #3
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: very stuck on a program, need major help!

    Hi,

    You have got things a bit back to front through a misunderstanding of what you are doing. If we stick with the idea you have chosen at the moment then the first thing to understand is that this line:-

    vb.net Code:
    1. Private SeatingArray(8, 3) As CheckBox

    Is creating an Array of CheckBoxes and you therefore need to treat all the Elements of that Array as CheckBoxes and nothing else.

    The first thing to note is that you then tried to assign your CheckBoxes to the Array but you got it the wrong way round. You should have said:-

    vb.net Code:
    1. SeatingArray(0, 0) = CheckBox1
    2. SeatingArray(0, 1) = CheckBox2
    3. SeatingArray(0, 2) = CheckBox3
    4. SeatingArray(0, 3) = CheckBox4
    5. 'etc...

    The next thing to note is that you then try to assign values to that Array as though it were an Array of Strings, which it is not. What you need to do is to assign Values to the Properties of the CheckBoxes contained within the Elements of the Array.

    In this case you want to assign a Name and Meal to the CheckBox but as you should know there is no property to allow you to set a Name and Meal to a CheckBox so you need to choose an appropriate property of the CheckBox to hold this arbitrary information. The Tag Property of every Control is provided to allow you to do exactly that. So, what you could have said is:-

    vb.net Code:
    1. SeatingArray(0, 0).Tag = "Tristan Forbes, Veg"
    2. SeatingArray(0, 1).Tag = "Alicia Forbes, Beef"
    3. SeatingArray(0, 2).Tag = "Karen Schumacher, Fish"
    4. SeatingArray(0, 3).Tag = "Dan Johnson, Fish"
    5. 'etc...

    The final part of your puzzle is the ToolTip. So, add a ToolTip Component to your Project and then to assign a ToolTip to the CheckBoxes you can use the SetToolTip Method. Here is an example:-

    vb.net Code:
    1. ToolTip1.SetToolTip(SeatingArray(0, 0), SeatingArray(0, 0).Tag.ToString)
    2. ToolTip1.SetToolTip(SeatingArray(0, 1), SeatingArray(0, 1).Tag.ToString)
    3. ToolTip1.SetToolTip(SeatingArray(0, 2), SeatingArray(0, 2).Tag.ToString)
    4. ToolTip1.SetToolTip(SeatingArray(0, 3), SeatingArray(0, 3).Tag.ToString)
    5. 'etc...

    Hope that helps.

    Cheers,

    Ian

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    73

    Re: very stuck on a program, need major help!

    This did help clarify a lot. What about setting the classes for certain seats? For example, I need 4 first class seats, and the cost for them would be (TicketPrice*4), but I don't know how to assign that to certain seats when the seats are just check boxes.

  5. #5
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: very stuck on a program, need major help!

    Hi,

    This is where you need to expand on what you have already learnt. As you now know the Tag Property can hold any Type of Object and therefore does not just have to be a string. So, what you can do now is to create a Class Object that holds all the relevant information for each and every seat on the aircraft. How about something like:-

    vb.net Code:
    1. Public Class AirlineSeat
    2.   Public Property ClassOfSeat As String
    3.   Public Property PassengerName As String
    4.   Public Property SelectedMeal As String
    5.   Public Property SeatPrice As Decimal
    6.  
    7.   Public Overrides Function ToString() As String
    8.       Return String.Format("Seat Class: {1}{0}Passenger Name: {2}{0}Selected Meal: {3}{0}Seat Price: {4:C}", Environment.NewLine, ClassOfSeat, PassengerName, SelectedMeal, SeatPrice)
    9.       Return MyBase.ToString()
    10.   End Function
    11. End Class

    You can then assign this to the Array like this:-

    vb.net Code:
    1. Dim seatNo1 As New AirlineSeat
    2. With seatNo1
    3.   .ClassOfSeat = "First"
    4.   .PassengerName = "Andy Jacobs"
    5.   .SelectedMeal = "Fish & Chips"
    6.   .SeatPrice = 400
    7. End With
    8. SeatingArray(0, 0).Tag = seatNo1
    9. 'etc...

    Finally, and because we created our own Custom ToString Method in the AirlineSeat Class, you can get the tool tip working by saying:-

    vb.net Code:
    1. ToolTip1.SetToolTip(SeatingArray(0, 0), DirectCast(SeatingArray(0, 0).Tag, AirlineSeat).ToString)
    2. 'etc...

    I will now leave this to you to finish.

    Hope that helps.

    Cheers,

    Ian

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    73

    Re: very stuck on a program, need major help!

    This was a huge help. I do have another question though. I misunderstood how the program was to be done. I'm not supposed to assign the name and meal of each person to each seat. I need to have a text box to enter the name, and then I'm thinking probably a drop down list box to choose the meal? I think that would be the best choice. But I think I need to have the tag property set on the checkboxes, not to the array. This is what my teacher said:

    In the Barely Aviation application you should use the tag of each seat checkbox to store its seat number....chkSeat1 should have tag 1, chkSeat2 should have tag property 2, etc. You must set these to get this to work correctly....Since you should only have one procedure to handle all of the seat controls, yes, one procedure.

    So do I set the check boxes to the array just like you stated above and then do something like checkbox1.Tag = txtName.Text ? Can you do that with a tag property?

    Lastly, in the above comment where you said to set the price of the seat using a "With" statement, it doesn't look like that will work how I need it to because there are different costs for different locations of the flights, along with the fact that each class is a different price (i.e. economy is the basic price, business is the ticket price*2, first class is ticket price*4) so I need to set a calculation to certain seats. Thanks again for your help. I really appreciate it!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2015
    Posts
    73

    Re: very stuck on a program, need major help!

    My teacher said we are not supposed to assign the check boxes to the array, but assign a number to the tag property to associate it with that number seat...but I don't really understand how to do that. I'm really lost here.

  8. #8
    Junior Member
    Join Date
    Oct 2015
    Posts
    16

    Re: very stuck on a program, need major help!

    It looks like a lot of MY questions on this have been answered, but I have some of my own.

    I was able to get the input boxes for the passenger name and meal choice, but when I hover my mouse, it only says "Name".

    Code:
      Dim myControl As New CheckBox
    
            strPassengers(CInt(myControl.Tag), 0) = InputBox("Enter Name: ", "Name")
            strPassengers(CInt(myControl.Tag), 1) = InputBox("Meals: " & ControlChars.CrLf & ControlChars.Tab & "Veggie" & ControlChars.CrLf & ControlChars.Tab & "Chicken" & ControlChars.CrLf & ControlChars.Tab & "Beef" & ControlChars.CrLf & ControlChars.Tab & "Fish", "Flight Menu")
    
            myControl = CType(CObj(sender), CheckBox)
    
            If (myControl.Checked) Then
                myControl.BackColor = Color.Red
                ttpSeats.SetToolTip(myControl, "Name") 'replace with what is stored in the array
            Else
                myControl.BackColor = Color.Yellow
                ttpSeats.SetToolTip(myControl, "Open Seat")
            End If
    The hiccup is commented--my question is how do I replace "Name" with what is stored in the array?

    Code:
    Option Strict On
    Option Explicit On
    
    Public Class frmMain
    
        Private strPassengers(35, 1) As String
    
        Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim myControl As Control
    
            For Each thisControl As System.Windows.Forms.Control In Me.Controls
    
                If CInt(thisControl.Tag) > 0 Then
                    thisControl.BackColor = Color.Yellow
                    thisControl.Text = "Seat" & ControlChars.CrLf & thisControl.Tag.ToString()
                End If
            Next thisControl
    
        End Sub
    
        Private Sub buySeat(sender As Object, e As EventArgs) Handles chkSeat1.CheckedChanged, chkSeat2.CheckedChanged, chkSeat3.CheckedChanged, chkSeat4.CheckedChanged, chkSeat5.CheckedChanged, chkSeat6.CheckedChanged, chkSeat7.CheckedChanged, chkSeat8.CheckedChanged, chkSeat9.CheckedChanged, chkSeat10.CheckedChanged, chkSeat11.CheckedChanged, chkSeat12.CheckedChanged, chkSeat13.CheckedChanged, chkSeat14.CheckedChanged, chkSeat15.CheckedChanged, chkSeat16.CheckedChanged, chkSeat17.CheckedChanged, chkSeat18.CheckedChanged, chkSeat19.CheckedChanged, chkSeat20.CheckedChanged, chkSeat21.CheckedChanged, chkSeat22.CheckedChanged, chkSeat23.CheckedChanged, chkSeat24.CheckedChanged, chkSeat25.CheckedChanged, chkSeat26.CheckedChanged, chkSeat27.CheckedChanged, chkSeat28.CheckedChanged, chkSeat29.CheckedChanged, chkSeat30.CheckedChanged, chkSeat31.CheckedChanged, chkSeat32.CheckedChanged, chkSeat33.CheckedChanged, chkSeat34.CheckedChanged, chkSeat35.CheckedChanged, chkSeat36.CheckedChanged
            Dim myControl As New CheckBox
    Where am I going wrong?

  9. #9
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: very stuck on a program, need major help!

    Quote Originally Posted by JohnBroyles View Post
    I
    The hiccup is commented--my question is how do I replace "Name" with what is stored in the array?
    If this part adds a name,
    Code:
    strPassengers(CInt(myControl.Tag), 0) = InputBox("Enter Name: ", "Name")
    then wouldn't you use that same code to get the name back?
    Code:
    ttpSeats.SetToolTip(myControl, strPassengers(CInt(myControl.Tag), 0))

  10. #10
    Junior Member
    Join Date
    Oct 2015
    Posts
    16

    Re: very stuck on a program, need major help!

    [QUOTE=Edgemeal;4953123]If this part adds a name,

    then wouldn't you use that same code to get the name back?
    Code:
    ttpSeats.SetToolTip(myControl, strPassengers(CInt(myControl.Tag), 0))
    I just tried that and got nothing when I hovered over the button. Once I cleared everything out (click on the button again and clear the input boxes), it showed "Open Seat like it was supposed to.

  11. #11
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: very stuck on a program, need major help!

    Hello
    I would like to say that you are over thinking this assignment, but I won't until I get more information.
    What are the exact directions for this assignment?
    How are you supposed to use and display the ticket cost?
    What is the flow of the running program? Here is a brief description of what I guess it to be.
    when you run the program the first thing the form displays is groupbox named "Destination" with 4 checkboxes , one for each possible destination
    you check one of them and three group boxes display the first groupbox has a name of "First Class" and four checkboxes one each for the four first class seats. The second groupbox is named "Business Class" and has 8 checkboxes one for each of the business class seats. The Third groupbox is named "Economy Class" and has 24 seats one for each economy seat.
    you check one of the boxes and textbox displays along with a groupbox named "Menu" which displays 4 check boxes one for each meal. You enter in the textbox the customers name then check their meal. The cost of their flight is dealt with and the textbox and groupbox "Menu" are removed. If at anytime you mouse over any seat for any flight the person's name and meal show as a tooltip.
    This is a broad attempt at showing the flow.
    The most important thing to do is design the form FIRST. Everything else including the code will fall into place for you.
    You may choose a different flow or be required to use a different one, THAT'S OKAY. Briefly describe it so when I see your code I will be better able to help.
    If you disagree or don't want my help be NICE I am only trying to help. I believe this is an beginning level program and should be coded as such, using beginning code commands. You are getting good advice from others, but I fear it is too advanced.
    Best OF Luck
    George
    Last edited by georgesutfin; Oct 30th, 2015 at 12:28 PM.

  12. #12
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: very stuck on a program, need major help!

    Do you not think the assignment would of been submitted 7 months ago?

  13. #13
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: very stuck on a program, need major help!

    I wondered about that! Why is it showing in the current postings? I assumed the date was some type of error. JohnBroyles made his posting yesterday!
    George
    Last edited by georgesutfin; Oct 30th, 2015 at 05:24 PM.

  14. #14
    Junior Member
    Join Date
    Oct 2015
    Posts
    16

    Re: very stuck on a program, need major help!

    Yes I did. Different semester, same problem

  15. #15
    Junior Member
    Join Date
    Oct 2015
    Posts
    16

    Re: very stuck on a program, need major help!

    Quote Originally Posted by georgesutfin View Post
    Hello
    I would like to say that you are over thinking this assignment, but I won't until I get more information.
    What are the exact directions for this assignment?
    Since you asked, here are the exact instructions for the assignment. I have omitted the first of my headaches which has been fixed.


    Barely Aviation needs a seating chart for flight sales (only one flight at a time needs to be tracked--they only have one plane). The following is the information that was provided by the owner, Denise R. Nockin. (A minimum of one multi-dimensional array is required for this assignment).

    Barely Aviation flies only one plane to the following cities for teh prices shown for an Economy Class seat from the Greater Peoria Airport:
    Lickskillet, OH (250)
    Toad Suck, AR (300)
    Peculiar, MO (100)
    Greasy, OK (400)

    You only need to do the chart for one destination at at time, since they only own one plane (selected by a drop box). Seating is based on a three-tier multiplier system with seat cost based on the Economy class multiplied by a class multiplier (EX: economy to Greasy, OK is $400, but first class is $1600 (400 * 4), and a business class is 800 (400 * 2).:
    Economy: x1
    Business: x2
    First: x4

    The following are the seats on the plane:

    24 Economy
    8 Business
    4 First

    Ms. Nockin wishes to track the following information and display the CURRENT status of each:
    Cost of flight based on expenses of economy price of seat to any destination * number of seats (36) on the flight * 1/2
    How many seats are sold and how much money is made per seating class
    Total revenue
    Net revenue
    Total seats sold

    A seating manifest should be visible when a checkbox is selected by the agent or Ms. Nockin
    If a reservation is cancelled, the program should handle the entire transaction by just unselecting the seat. <---next headache

    Now to work on the cancellation item.

  16. #16
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: very stuck on a program, need major help!

    please let this thread die, If you have your own question then start a new thread.

  17. #17
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: very stuck on a program, need major help!

    Thank you for the instructions.
    I am sorry, but I don't see how the information (which flight, what type of seat, persons name, meal choice) are to be done? Do you hard code the information?
    How are you going to construct the seating manifest? If you use a bank of buttons, Then when you select one (that is click on it) you could add a reservation or remove one, based on it's backcolor.
    George

  18. #18
    Junior Member
    Join Date
    Oct 2015
    Posts
    16

    Re: very stuck on a program, need major help!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width