VB code partially runs,,Can't see the problem [modified]
-
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.Visi -
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.VisiIt would be nice if you would put your code in some <pre></pre> tags so it easy to read.
-
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.VisiI second that; it is unreadable right now. You could still edit the existing message though. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
I second that; it is unreadable right now. You could still edit the existing message though. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
It would be nice if you would put your code in some <pre></pre> tags so it easy to read.
-
I have no idea how to use those tags. When I said newbie I meant very new. Like a baby just born.
Do this when you edit your message: <pre> **Your code here** </pre>
-
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.Visidorkpixie wrote:
appears to do nothing at all
What does that mean? You click the button and no code runs? You click the button and the code runs but gives no output? Have you stepped through the code using the debugger?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
I have no idea how to use those tags. When I said newbie I meant very new. Like a baby just born.
Edit your post. Select the code segments then click on the "code block" link on the line above :)
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
When I pasted the code it was indented. I do not know how to indent other than using the tab key... I'm sorry.
outside of PRE tags, tabs are just spaces, and multiple spaces get ignored. Inside PRE tags, it all works pretty much like in a code editor. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Edit your post. Select the code segments then click on the "code block" link on the line above :)
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
dorkpixie wrote:
appears to do nothing at all
What does that mean? You click the button and no code runs? You click the button and the code runs but gives no output? Have you stepped through the code using the debugger?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
Click the button and get no output at all. No errors either. Weirdest non running code I have ever written.
Okay if you click the button and no code runs at all, check that the button is actually hooked up to the function through the Events property sheet. If the button is hooked to the event handler then set a breakpoint in the event handler and step through the code until you narrow down where the problem is.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
You're welcome. Looks much more gooder :-)
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.Visi- in your btnTicketCost, and an else clause to the If block, and display a validation error message, your Validate Ticket might never be returning True, hence never resulting in any output. 2) If #1 above never returns True, start putting debug statements in the function to try and establish which part(s) is/are causing the validation to fail.
Dave Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com -
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.VisiFirst, they told you about the pre tag, but what they didn't tell you was that you can specify which language you're using which helps with the coloring. In your case, you're pre tags should look like: <pre lang="vbnet"> Beyond that, I'll just comment on what I see... I don't know if your assignment was to use decimal types or not, but it doesn't look like it's necessary since you're dealing wholly with integer values and should never get any decimal values. I also don't know if you were told to use Select Case statements, but you can use If/Else if they're small statments...for instance you wrote:
Select Case intTicketChoice
Case 0
SeasonTickets()
Case 1
SingleGameTickets()
End Selectwhich is a total of 11 words and 78 characters.
If intTicketChoice = 0 Then
SeasonTickets()
Else
SingleGameTickets()
End Ifis 10 words and 66 characters. Also, the If/Else should be streamlined as far as the number of cycles it takes to evaluate since I assume the Select Case just builds a series of If/ElseIf statements. Let's start with
btnTicketCost_Click
. You have some strange code here. First, what is it that it needs to do? Well, it looks like it needs to check to make sure that a ticket type was selected and that an appropriate number of tickets were selected for purchase and then adds up the total. So what is it that you actually do? You createintNumberTix
, but then you never set it to anything. You then run a function to validate the number of tickets. That checks to see if the number in the TextBox was between 1 and 20. If it isn't, you show a MessageBox asking them to re-enter the number of tickets, I guess. First, thatValidateNumberTix
is way too long. It could just be:Private Function ValidateNumberTix() as Boolean
If Not IsNumeric(Me.txtNumberOfTickets.Text) Then
ResetNumberTix()
Return False
Else
Dim intNumberTix As Long = CLng(Me.txtNumberOfTickets.Text)
If intNumberTix < 1 Or intNumberTix > 20 Then
ResetNumberTix()
Return False
End If
End If
Return True
End FunctionPrivate Sub ResetNumberTix()
MessageBox.Show("Please enter the number of tickets you would like to buy (1-20)", "Error")
Me.txtNumberOfTickets.Focus()
Me.txtNumberOfTickets.Clear()
End SubYou create extra variables in memory that you don't need which take extra cycles. Back to
-
Hi, I am newbie here; I hope that I am posting correctly. If not please let me know and I will fix that after this post... So here is my dilemma. Thank you for any help in advance. :) The program loads; I can pick a ticket type and the appropriate seats are listed in lstbox. I can type in how many ticket I want and clear the form. The Calculate cost button appears to do nothing at all. VB editor does not even give me an error; it just doesn't do anything. This was a homework, I have already handed it in though as is, so now I am just looking for guidance on where I went wrong. I don't want to move onto the next subject if I can't understand this one. Purpose: This application allows the user to unput data about ' the purchase of baseball tickets. Once the data is entered, ' the program will compute the cost of the tickets purchased. Option Strict On
Public Class frmBaseBallTicketSales
'Class Variables
Private _decSeasonBoxSeat As Decimal = 2500D
Private _decSeasonLowerSeat As Decimal = 1500D
Private _decSingleBoxSeat As Decimal = 55D
Private _decSingleLowerSeat As Decimal = 35D
Private _decUpperSeat As Decimal = 25D
Private _decStanding As Decimal = 15D
Private _strSeasonBoxSeats As String = "Box Seats $2500"
Private _strSeasonLowerDeck As String = "Lower Deck Seats $1500"
Private _strSingleBoxSeats As String = "Box Seats $55"
Private _strSingleLowerDeck As String = "Lower Deck Seats $35"
Private _strUpperDeck As String = "Upper Deck Seats $25"
Private _strSRO As String = "Standing Room Only $15"Private Sub cboTicketType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboTicketType.SelectedIndexChanged
'This event handler allows the user to enter choices on form.
'Then it calls subprocesures to place seats in list box.Dim intTicketChoice As Integer intTicketChoice = Me.cboTicketType.SelectedIndex Me.lstSeats.Items.Clear() Select Case intTicketChoice Case 0 SeasonTickets() Case 1 SingleGameTickets() End Select
'Make items visible in window.
Me.lblNumberOfTickets.Visible = True
Me.txtNumberOfTickets.Visible = True
Me.lblSeatType.Visible = True
Me.lstSeats.Visible = True
Me.btnTicketCost.Visible = True
Me.btnClear.Visible = True
Me.lblCost.VisiBTW...the simple answer is #1) You never set intNumberTix #2) You use intSeatType twice meaning two different things...first the seat type (lower, box, etc...), then the ticket type (season vs. single)
'Call a function to make sure ticket type selected. **intSeatType** = ValidateSeatSelection(blnSeatTypeIsSelected, strSelectedSeat) 'If the number of tickets ordered is valid, calculate the cost. If (blnNumberTixIsValid And blnSeatTypeIsSelected) Then **intSeatType** = Me.cboTicketType.SelectedIndex Select Case intSeatType Case 0 decTotalCost = SeasonTicketsFindCost(**intSeatType**, \_ intNumberTix) Case 1 decTotalCost = SingleTicketsFindCost(**intSeatType**, \_ intNumberTix) End Select
-
First, they told you about the pre tag, but what they didn't tell you was that you can specify which language you're using which helps with the coloring. In your case, you're pre tags should look like: <pre lang="vbnet"> Beyond that, I'll just comment on what I see... I don't know if your assignment was to use decimal types or not, but it doesn't look like it's necessary since you're dealing wholly with integer values and should never get any decimal values. I also don't know if you were told to use Select Case statements, but you can use If/Else if they're small statments...for instance you wrote:
Select Case intTicketChoice
Case 0
SeasonTickets()
Case 1
SingleGameTickets()
End Selectwhich is a total of 11 words and 78 characters.
If intTicketChoice = 0 Then
SeasonTickets()
Else
SingleGameTickets()
End Ifis 10 words and 66 characters. Also, the If/Else should be streamlined as far as the number of cycles it takes to evaluate since I assume the Select Case just builds a series of If/ElseIf statements. Let's start with
btnTicketCost_Click
. You have some strange code here. First, what is it that it needs to do? Well, it looks like it needs to check to make sure that a ticket type was selected and that an appropriate number of tickets were selected for purchase and then adds up the total. So what is it that you actually do? You createintNumberTix
, but then you never set it to anything. You then run a function to validate the number of tickets. That checks to see if the number in the TextBox was between 1 and 20. If it isn't, you show a MessageBox asking them to re-enter the number of tickets, I guess. First, thatValidateNumberTix
is way too long. It could just be:Private Function ValidateNumberTix() as Boolean
If Not IsNumeric(Me.txtNumberOfTickets.Text) Then
ResetNumberTix()
Return False
Else
Dim intNumberTix As Long = CLng(Me.txtNumberOfTickets.Text)
If intNumberTix < 1 Or intNumberTix > 20 Then
ResetNumberTix()
Return False
End If
End If
Return True
End FunctionPrivate Sub ResetNumberTix()
MessageBox.Show("Please enter the number of tickets you would like to buy (1-20)", "Error")
Me.txtNumberOfTickets.Focus()
Me.txtNumberOfTickets.Clear()
End SubYou create extra variables in memory that you don't need which take extra cycles. Back to
There's a couple of things... You're help is awesome and easy to understand. However, since this is still a beginner VB class there are some things we have not been taught to use yet such as: Dim intNumberTix As Long = CLng(Me.txtNumberOfTickets.Text) have no idea what Long and CLng is.. and If lstSeats.SelectedItems.Count = 0 Then, we have not done counts yet. So while I generally understand what this means: If intSeatType = 0 Then lngTotalCost = SeasonTicketsFindCost(lstSeats.SelectedIndex, _ CInt(Me.txtNumberOfTickets.Text)) Else lngTotalCost = SingleTicketsFindCost(lstSeats.SelectedIndex, _ CInt(Me.txtNumberOfTickets.Text)) End If lblCost.Text = String.Format("{0:C}",lngTotalCost) I have never seen lng or Long as a variable type. I can however take what you have given me and put it into what we have learned. Sometimes in the introductory courses they kind of force you to use certain things. Such as the way the splash screen is timed. I am glad though that I have gotten feedback from others who have more experience so that I do not miss these lessons. Hopefully classes will get to them so I don't graduate with completely wrong information. Thank you again for your help. Do you want me to post working code when I finish it?
-
There's a couple of things... You're help is awesome and easy to understand. However, since this is still a beginner VB class there are some things we have not been taught to use yet such as: Dim intNumberTix As Long = CLng(Me.txtNumberOfTickets.Text) have no idea what Long and CLng is.. and If lstSeats.SelectedItems.Count = 0 Then, we have not done counts yet. So while I generally understand what this means: If intSeatType = 0 Then lngTotalCost = SeasonTicketsFindCost(lstSeats.SelectedIndex, _ CInt(Me.txtNumberOfTickets.Text)) Else lngTotalCost = SingleTicketsFindCost(lstSeats.SelectedIndex, _ CInt(Me.txtNumberOfTickets.Text)) End If lblCost.Text = String.Format("{0:C}",lngTotalCost) I have never seen lng or Long as a variable type. I can however take what you have given me and put it into what we have learned. Sometimes in the introductory courses they kind of force you to use certain things. Such as the way the splash screen is timed. I am glad though that I have gotten feedback from others who have more experience so that I do not miss these lessons. Hopefully classes will get to them so I don't graduate with completely wrong information. Thank you again for your help. Do you want me to post working code when I finish it?
Hmm...that's curious...you were taught about Decimals before Longs? A Long is just a larger Integer. Decimal is definitely not a standard type. The 4 standard VB numeric types are Integer, Long, Float, and Double. An Int is only good up to 32,767. A Long goes beyond that. CLng is just a conversion method. There are many of these...CInt, CDec, CLng, CDbl...So, if you pass in a string value to any of them, it will try to return whatever number is in that string in the selected type. Or it you pass an Integer into CDbl, it will return that Integer as a Double. As far as the SelectedItems.Count, that is just a property within the ListBox. I assume that since you are allowed to use a ListBox, you should be allowed to use any of its methods. That is just one of them. But, I know about profs not wanting you to skip ahead. In one of my classes, I read ahead and found the switch in C++ (the same as VB's Select) and used it instead of a series of for loops and was told that I wasn't to use something we hadn't been taught yet. And you may not feel like you need one, but when I was in college, I was a tutor and I hope that it helped the people that I tutored. Normally, schools provide the service free of charge and it can be really helpful to have someone who's gotten further helping you understand how to structure a program and even giving hints on what has worked for them and what hasn't.
-
Hmm...that's curious...you were taught about Decimals before Longs? A Long is just a larger Integer. Decimal is definitely not a standard type. The 4 standard VB numeric types are Integer, Long, Float, and Double. An Int is only good up to 32,767. A Long goes beyond that. CLng is just a conversion method. There are many of these...CInt, CDec, CLng, CDbl...So, if you pass in a string value to any of them, it will try to return whatever number is in that string in the selected type. Or it you pass an Integer into CDbl, it will return that Integer as a Double. As far as the SelectedItems.Count, that is just a property within the ListBox. I assume that since you are allowed to use a ListBox, you should be allowed to use any of its methods. That is just one of them. But, I know about profs not wanting you to skip ahead. In one of my classes, I read ahead and found the switch in C++ (the same as VB's Select) and used it instead of a series of for loops and was told that I wasn't to use something we hadn't been taught yet. And you may not feel like you need one, but when I was in college, I was a tutor and I hope that it helped the people that I tutored. Normally, schools provide the service free of charge and it can be really helpful to have someone who's gotten further helping you understand how to structure a program and even giving hints on what has worked for them and what hasn't.
William, Thank you very much for your insights and help. i do not think this particular professor would knock me for going ahead but I didn't want to try him. When I got his reveiw of my homework he said, "There were only two problems with {my} code which were giving {me} problems. The first problem is {I} forgot to set the number of tickets based on the entered value for the number of tickets. The other problem is {my} line for converting the value to string {....} Should be:
'display cost.
lblCost.txt = decTotalCost.ToString"Once {he} fixed those things the program worked great." Now, I agree with you that there was just too much code. But in an introductory class they are looking that mainly the program works and that the UI does what it is supposed to do. I was surprised that I got an A but pretty happy. The Decimal thing; as you can see my prof also used decimal, the program assignment as written in the book, wants the total cost to be in the format of $8888.00. So we were kind of forced into the dec format; I found it annoying as well since it added to the code and also made it confusing when working with both integers and decimals. Anyway, I found all of you expertise helpful and if I could afford to pay you to tutor; I would see if you were up for the challenge; however like most students I am poooooor. The university at this time does not have VB tutors, but as soon as they do, they will let me know. ;) Thank you again. I will definitely be back!! This site is awesome as a resource and for help. Oh, and we're learning arrays this unit so I may need the help ;0 Thanks again, looking forward to talking with you again.