3 Replies - 11136 Views - Last Post: 01 April 2013 - 11:22 AM Rate Topic: -----

#1 tskubeljr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 10

Stuck on a Workshop selector homework assignment

Posted 16 November 2010 - 07:49 PM

I am working on a few assignments for Visual Basic 2008. The book just doesn't give me enough example. I learn by example best and this is a new "web-enhanced" course where we are only in the classroom every other week for 3 hours. This being said I don't get a lot from reading a book, I learn much more from example. With that here is the program I am working on:

Workshop Selector:
3 list boxes, 4 buttons, 2 labels.
The application allows the user to select a workshop from lstWorkshop, Then select a location from lstLocation. Next btnAdd takes the selected workshop and location attached to a set amount of days and a registration fee and multiplies the days by a Lodging fee and outputs this number in dollar form. After multiple workshops/locations have been added btnCalc adds each of these and places them in lblTotal. The other two buttons are exit and clear which have already understand (of course the "easy" stuff)

Here is my code:

Public Class Form1
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

'Declare values from both listboxes
Dim Day, Fee, Stay, Total As Integer

'Workshop selection
Dim workshop As String = lstWorkshop.SelectedIndex()
If lstWorkshop.SelectedItem = "Handling Stress" Then
Day = 3 And Fee = 595
ElseIf lstWorkshop.SelectedItem = "Time Management" Then
Day = 3 And Fee = 695
ElseIf lstWorkshop.SelectedItem = "Supervision Skills" Then
Day = 3 And Fee = 995
ElseIf lstWorkshop.SelectedItem = "Negotiation" Then
Day = 5 And Fee = 1295
ElseIf lstWorkshop.SelectedItem = "How to Interview" Then
Day = 1 And Fee = 395
ElseIf lstWorkshop.SelectedItem Is Nothing Then
MsgBox("Please choose a workshop first")
End If

'Location selection
Dim location As String = lstLocation.SelectedIndex()
If lstLocation.SelectedItem = "Austin" Then
Stay = Day * 95
ElseIf lstLocation.SelectedItem = "Chicago" Then
Stay = Day * 125
ElseIf lstLocation.SelectedItem = "Dallas" Then
Stay = Day * 110
ElseIf lstLocation.SelectedItem = "Orlando" Then
Stay = Day * 100
ElseIf lstLocation.SelectedItem = "Phoenix" Then
Stay = Day * 92
ElseIf lstLocation.SelectedItem = "Raleigh" Then
Stay = Day * 90
ElseIf lstLocation.SelectedItem Is Nothing Then
MsgBox("Please choose a location first")
End If

'Total cost
Total = Stay + Fee

'Display in list box
lstCost.Items.Add(Total.ToString("c"))
End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
lstWorkshop.SetSelected(0, False)
lstLocation.SetSelected(0, False) ' clear all listboxes and Total label
lstCost.Items.Clear()
lblTCost.Text = ""

End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close() 'exit application
End Sub

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click

End Sub
End Class



My btnAdd button will only place "$0.00 in the third listbox from there I am stuck... Please if you care to take the time and read this and help me please explain that will be the most help of all. Thank you all for your time

Tom

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Stuck on a Workshop selector homework assignment

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Stuck on a Workshop selector homework assignment

Posted 16 November 2010 - 08:51 PM

Begin by learning to use the Debugger,

Set Breakpoints on each method and step-through the program, examining each variable.
As the code is not doing what you think it does.

This post has been edited by AdamSpeight2008: 16 November 2010 - 09:15 PM

Was This Post Helpful? 2
  • +
  • -

#3 tskubeljr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 10

Re: Stuck on a Workshop selector homework assignment

Posted 18 November 2010 - 06:25 AM

View PostAdamSpeight2008, on 16 November 2010 - 07:51 PM, said:

Begin by learning to use the Debugger,

Set Breakpoints on each method and step-through the program, examining each variable.
As the code is not doing what you think it does.


Thanks Adam, from using this process, that I was never shown even exisited I resolved my issues and completed my assignment! Consider this post resolved and closed...

Thanks again, Tom
Was This Post Helpful? 0
  • +
  • -

#4 Tonyrg1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-March 13

Re: Stuck on a Workshop selector homework assignment

Posted 01 April 2013 - 11:22 AM

View Posttskubeljr, on 18 November 2010 - 06:25 AM, said:

View PostAdamSpeight2008, on 16 November 2010 - 07:51 PM, said:

Begin by learning to use the Debugger,

Set Breakpoints on each method and step-through the program, examining each variable.
As the code is not doing what you think it does.


Thanks Adam, from using this process, that I was never shown even exisited I resolved my issues and completed my assignment! Consider this post resolved and closed...

Thanks again, Tom

Hi,
I just wanted to know what you coded for the calculate button? Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1