-
Apr 12th, 2012, 10:06 AM
#1
Thread Starter
Lively Member
Debugging help
.........................................................
Last edited by CrisHooker27; Apr 12th, 2012 at 02:02 PM.
-
Apr 12th, 2012, 10:54 AM
#2
Re: Debugging help
I for one will not be downloading any ZIP files. Just post the relevant code (and only the relevant code) directly and explain exactly what the problem is.
-
Apr 12th, 2012, 11:54 AM
#3
Thread Starter
Lively Member
Re: Debugging help
.........................................he structure. Any help in debugging this problem.
Last edited by CrisHooker27; Apr 12th, 2012 at 01:50 PM.
-
Apr 12th, 2012, 12:12 PM
#4
Re: Debugging help
Which lines of code are causing the error?
One thing, you seem to be using Section and Price as if they are arrays, they are not. TicketsSold is what was declared an array. So, try TicketsSold(0).Price.
-
Apr 12th, 2012, 12:16 PM
#5
Thread Starter
Lively Member
Re: Debugging help
.................................................
Last edited by CrisHooker27; Apr 12th, 2012 at 01:50 PM.
-
Apr 12th, 2012, 12:29 PM
#6
Re: Debugging help
I believe that Dim is the same as Private, though I haven't tested this rigorously. If that is the case, then by declaring all the members of the Structure with Dim, you have effectively made them private, which would make them invisible to any code that attempted to access them. The simple solution to that is to make the members Public, since that is what you want them to be anyways:
Code:
Public Structure TicketSales
Public Section As String
Public Price As Decimal
Public TicketsSold As Integer
End Structure
My usual boring signature: Nothing
-
Apr 12th, 2012, 12:29 PM
#7
Re: Debugging help
I don't do PM. I don't want to download your project.
Shaggy, I tried this and it worked
Public Structure TicketSales
Dim Section As String
Dim Price As Decimal
Dim TicketsSold As Integer
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare an array of the sturcture
Dim TicketsSold(3) As TicketSales
TicketsSold(0).Price = 11
MsgBox(TicketsSold(0).Price.ToString)
-
Apr 12th, 2012, 12:32 PM
#8
Thread Starter
Lively Member
Re: Debugging help
................................................................
Last edited by CrisHooker27; Apr 12th, 2012 at 02:02 PM.
-
Apr 12th, 2012, 12:44 PM
#9
Re: Debugging help
Which lines of code are causing the error?
Also, your still trying to use Price and Section as arrays, eg.
Code:
SelectedPriceDecimal = Price(SectionsListBox.SelectedIndex)
Code:
SectionsListBox.Items.Add(Section(i))
Last edited by wes4dbt; Apr 12th, 2012 at 12:55 PM.
-
Apr 12th, 2012, 12:59 PM
#10
Thread Starter
Lively Member
Re: Debugging help
Yes those are the line that are in error, and I must keep it in VB2010 FORMAT not in previous versions or else I get a zero
-
Apr 12th, 2012, 01:09 PM
#11
Re: Debugging help
Is the problem solved? If so, please mark the thread as resolved.
-
Apr 12th, 2012, 01:13 PM
#12
Thread Starter
Lively Member
Re: Debugging help
/.................................
Last edited by CrisHooker27; Apr 12th, 2012 at 01:52 PM.
-
Apr 12th, 2012, 01:24 PM
#13
Re: Debugging help
Yes those are the line that are in error, and I must keep it in VB2010 FORMAT not in previous versions or else I get a zero
I don't understand that statement. If those are the lines that are causing the error, then fix it. It will still be in "VB2010 Format".
BTW you don't have anything assigned to "TicketsDSold(0).Section"
Code:
TicketsSold(1).Section = "Orchestra"
TicketsSold(0).Price = 40D
TicketsSold(1).Section = "Mezzanine"
-
Apr 12th, 2012, 01:47 PM
#14
Thread Starter
Lively Member
Re: Debugging help
............................................................... and did not fix anything
Last edited by CrisHooker27; Apr 12th, 2012 at 06:31 PM.
-
Apr 12th, 2012, 03:49 PM
#15
Re: Debugging help
I explainded the error in my very first post. Instead of "section(i)" or "price(i)" you need to reference the structure array, like "TicketsSold(i).Section".
If that doesn't solve the problem then show the line of code that causes the error.
-
Apr 12th, 2012, 03:50 PM
#16
Thread Starter
Lively Member
Re: Debugging help
Roger that Ill run it and get back to you
-
Apr 12th, 2012, 06:03 PM
#17
Thread Starter
Lively Member
Re: Debugging help
...........................................................................
Last edited by CrisHooker27; Apr 12th, 2012 at 07:20 PM.
-
Apr 12th, 2012, 07:09 PM
#18
Re: Debugging help
That because you didn't fix it!
Code:
SeatTextBox.Text = Price(SectionsListBox.SelectedIndex)
-
Apr 12th, 2012, 07:17 PM
#19
Thread Starter
Lively Member
Re: Debugging help
Originally Posted by wes4dbt
That because you didn't fix it!
Code:
SeatTextBox.Text = Price(SectionsListBox.SelectedIndex)
I did fix it, it did not work so I reverted it back to the original but it did work on the Section
-
Apr 12th, 2012, 07:49 PM
#20
Re: Debugging help
How was I suppose to know that and why would you put it back, when you know that code doesn't work.
You still won't post the line where the error occurs. You should have posted your new code and explained exactly which line of code is causing the error.
I give up, good luck
-
Apr 12th, 2012, 07:51 PM
#21
Thread Starter
Lively Member
Re: Debugging help
Thanx Wes for the help, still is appreciated
-
Apr 12th, 2012, 08:33 PM
#22
Re: Debugging help
What error did you get when you tried,
Code:
SeatTextBox.Text = TicketsSold(SectionsListBox.SelectedIndex).Price.ToString
Why did you remove the code you posted. No one can help you without seeing the current code.
-
Apr 12th, 2012, 08:34 PM
#23
Thread Starter
Lively Member
Re: Debugging help
........................................................
Last edited by CrisHooker27; Apr 13th, 2012 at 01:52 PM.
-
Apr 12th, 2012, 09:02 PM
#24
Re: Debugging help
It looks like your using all the elements of the structure to me. Are you still getting errors?
-
Apr 13th, 2012, 10:22 AM
#25
Thread Starter
Lively Member
Re: Debugging help
He says that when he runs the program he gets a
By the way you had an incorrect price for the of the secTions.
I have included notes and a couple of suggestions.
Also when I run this program without selecting a section it throws a run-time exception, which will be a major point deduction.
-
Apr 13th, 2012, 10:25 AM
#26
Thread Starter
Lively Member
Re: Debugging help
........................................................
Last edited by CrisHooker27; Apr 13th, 2012 at 01:52 PM.
-
Apr 13th, 2012, 11:49 AM
#27
Thread Starter
Lively Member
Re: Debugging help
Yea well it looked pretty dern sel evident to my self, guess i am not explaining it as he would like to hear it?
Well I will be back on this hustle later tonite I did a 38 mile bike ride earlier this morning and im hungry and sleepy
-
Apr 13th, 2012, 01:14 PM
#28
Re: Debugging help
sense you use the "selectedindex" method of the combobox as the array index, then you need to test that there is a selectedindex,
Code:
if SectionListBox.SelectedIndex>=0 Then
'do something
End If
You also need to test that there is a number entered in NumberTextBox, Instead of "Parse", use, TryParse.
Code:
Dim NumberInteger as Integer
If Integer.TryParse(NumberTextBox.Text, NumberInterger) Then
'do something
else
'show error and go back to the NumberTextBox
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|