|
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
|
|
|
|
|
1) 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.
|
|
|
|
|
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 Select
which is a total of 11 words and 78 characters.
If intTicketChoice = 0 Then
SeasonTickets()
Else
SingleGameTickets()
End If
is 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 create intNumberTix , 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, that ValidateNumberTix 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 Function
Private 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 Sub
You create extra variables in memory that you don't need which take extra cycles.
Back to btnTicketCost_Click . You can first just check if the number of tickets is valid and if it isn't, exit the sub. Then, you can check if the user made a ticket type selection. You can do this a lot simpler than you did. First, just check if there were any selected items using
If lstSeats.SelectedItems.Count = 0 Then
MessageBox.Show("Select a seat type", "Error")
Return
End If
Then, just make a function to return the seat type. (As an FYI, naming a method using the phrase "Validate" implies it will return a boolean. Using proper naming conventions can really help when trying to figure out what you did later). You passed into ValidateSeatSelection a variable name strSelectedSeat , which you then never used again. Once again, another unnecessary variable. You also set intSeatType twice.
I'm also quite confused about what values can be in intSeatType. Initially, you just check for 0 and 1. If it's 0, you go to SeasonTickets, if it's 1, SingleTickets. But, then within each of those function, you re-evaluate intSeatType and it apparently has a different meaning. I think you used the same variable name to check if it's supposed to be season tickets or single tickets, and for what type of seat it is.
I would rewrite it to something more like:
If Not ValidateNumberTix() Then Return
If lstSeats.SelectedItems.Count = 0 Then
MessageBox.Show("Select a seat type", "Error")
Return
End If
Dim intSeatType As Integer = Me.cboTicketType.SelectedIndex
Dim lngTotalCost as Long
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)
Again, Decimal is really only needed when dealing with cents. When dealing with whole numbers, you shouldn't see any problems with multiplication. Decimal takes a lot more overhead and is a lot slower than just using a long or integer.
And, instead of sleeping the thread for the splash screen, you would be better off using a Timer. If the user clicks on the splash screen during that 5 seconds, it could end up looking funny. Just use a timer, set it to tick every 5000 milliseconds and when the timer ticks, just close the form.
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|
|
BTW...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)
intSeatType = ValidateSeatSelection(blnSeatTypeIsSelected, strSelectedSeat)
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
|
|
|
|
|
Hi, i'm having a problem on put a menustrip on a mdi children, when i load my project, the "bar" appears, but the options(itens) doesn't, does anyone knows what is the problem? thank you
Marcus Abrahão
|
|
|
|
|
do you have an options menu on the parent form? if so they more than likely have merged
Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
|
|
|
|
|
wow, thank you very much... i just put the allowmerge = false and solved
|
|
|
|
|
Hi, dear all,
I was past a project created years ago and will do some change on it.
From its document it said this project is ceated Microsoft development environment (Windows and Visual Basic), here VB should be VB6.0.
But I saw some files with extension .scc, I search internet and know this file is from Visual SourceSafe.
I didn't install Visual SourceSafe in my computer, and I will work on this project alone. I have no idea what should I do now. What's the relationship of VSS and VB? Do I need to install VSS? Should I work on the project in VB environment or .NET or others?
Thanks!
|
|
|
|
|
By the way, I already use PVCS as source control tool. Thansk!
|
|
|
|
|
I have never used VSS, but image the files will just be used to keep track of what each file status is.
I would imagine that you can carry on working with the project and just delete/ignore the files. Certainly this is what i have done with SVN projects.
What to do is take a copy of the original files, work on the copy and see what happens, if it all goes wrong just revert back.
|
|
|
|
|
Dave,
Thank you for reply.
VSS is just for source control, right? So I can forget about it and continue work on the project in VB6, am I right?
The original project create setup file with some script file (extension .wse), does the setup file creation have relationship with VSS?
Thanks!
|
|
|
|
|
Andraw Tang wrote: VSS is just for source control, right? So I can forget about it and continue work on the project in VB6, am I right?
As far as i know, yes, just carry on using VB6 on the project files.
Andraw Tang wrote: The original project create setup file with some script file (extension .wse), does the setup file creation have relationship with VSS?
That i do not know, are wse files not just plaintext? can you not look at the files content and see what is within?
|
|
|
|
|
Hi, Dave,
WSE file contains something like the following:
Document Type: WSE
item: Global
Version=8.1
Title=VB6 Runtime Installation
Title French=VB6 Runtime Installation
Title German=VB6 Runtime Installation
Title Spanish=VB6 Runtime Installation
Title Italian=VB6 Runtime Installation
Flags=00000100
Languages=65 0 0 66 67 0 68 0 69 0 0 0 0 0 0 0
Copy Default=1
Japanese Font Name=MS Gothic
Japanese Font Size=10
Progress Bar DLL=%_WISE_%\Progress\WIZ%_EXE_OS_TYPE_%.DLL
Start Gradient=0 0 255
End Gradient=0 0 0
Windows Flags=00000100000000110010110000011000
Log Pathname=%MAINDIR%\INSTALL.LOG
Message Font=MS Sans Serif
Font Size=8
Pages Modified=00000001000000000000000000000000
Disk Filename=SETUP
Patch Flags=0000000000000001
Patch Threshold=85
Patch Memory=4000
FTP Cluster Size=20
Per-User Version ID=1
Dialogs Version=6
Crystal Format=10111100101100000010001001001001
Step View=Properties
end
item: Remark
end
remarked item: If/While Statement
Value=UCase$(Left$(CMDLINE,2)) <> "/T"
Flags=00001101
end
remarked item: Remark
Text=System Must have NT 4.0+ or Win9x running to install software properly.
end
remarked item: Check Configuration
Message=This VB6 application requires Windows 95 or NT 4.0 to run. Please install this software on another computer or upgrade your operating system.
Title=Incompatible Operating System
Title French=Système d'exploitation incompatible
Title German=Inkompatibles Betriebssystem
Title Portuguese=Sistema operativo incompatível
Title Spanish=Sistema Operativo Incompatible
Title Italian=Sistema operativo incompatibile
Title Danish=Inkompatibelt Operativsystem
Title Dutch=Niet-compatibel systeem
Title Norwegian=Ikke kompatibelt operativsystem.
Title Swedish=Inkompatibelt operativsystem
Flags=01011011
end
I don't know what's the meaning.
I just wander do we need to create script file to create setup file? Do the wse file check some preconditon for installation?
Thanks!
|
|
|
|
|
I think the wse file is a project file for the installation project done with some version of the Wise Installation System or Wise for Windows Installer (probably the first). I would guess 8.1 is the Wise version used.
From what I can see, it checks for two things:
"System Must have NT 4.0+ or Win9x running to install software properly."
and
"This VB6 application requires Windows 95 or NT 4.0 to run. Please install this software on another computer or upgrade your operating system."
If I were you I'd clean up the project and remove the vss and wse files and package the whole shebang using a more contemporary installer.
|
|
|
|
|
John,
Thank you for your reply.
Yes. the wse file was created using Wise InstallMaster 8.1.
The reason I want to resue these files is that this project is a large one with more than 1000 files and more than 10 third party tool and all these tools need to be registered while install, and I just do a little change on it, like logo, image, application name, license info.... If I restart by a new tool, I am afraid I will lose some logic.
But I also have no idea how to modify the existing wse file, can you give me some instruction?
Thanks!
|
|
|
|
|
Hi guys, how can i check if a PC has Wake on lan enabled??
Thank you so much
|
|
|
|
|
Is this in anyway related to VB?
By posting in this forum, are you implying that you want to be able to check using a VB application if WOL is enabled, or do you just want to know i.e. using the control panel etc, if it is enabled?
|
|
|
|
|
Yes, i want to know how to check this using vb
|
|
|
|
|
Ok, i think you will need to do some further research, but this can be both checked and set using VB and WMI.
The link below has a script which can perform this from the command line;
http://forums.whirlpool.net.au/forum-replies-archive.cfm/919407.html[^]
What you will need to do is look for other examples (there are some on CP) on making WMI calls from VB, and then translate the script version calls to suit.
Happy problem solving!
|
|
|
|
|
Hi,
We are in the process of building a new enterprise application, that would comprise of an Oracle database, and a VB.NET application. Now my request to you all is to suggest the optimal architecture, in terms of technology, stability, maintenance, etc, bearing in mind that we would like to have a multi-tier application, with a thin client, and 1 to n business/persistence layers.
The application would be used by users who might be geographically separated.
Would appreciate your inputs on:
Winforms Vs ASP.NET?
Communication,
Data persistence,
Performance,
Any other criterion that you might consider important.
Your inputs would be highly appreciated.
Cheers/RB
|
|
|
|
|
RajeevBhatt wrote: Winforms Vs ASP.NET?
RajeevBhatt wrote: Communication
RajeevBhatt wrote: Performance
Windows forms (generally) give a faster, and more direct interactive experience to the user. Development will be easier. You will not be dependent on internet connections (or quality thereof)
RajeevBhatt wrote: The application would be used by users who might be geographically separated.
This is the key question, and I warmly suggest that you get a more committed answer from the customer.
RajeevBhatt wrote: Data persistence
In the case of "geographically separated users" ASP.NET (a web application) is much much easier for the application / data administrator(s), and will likely be much cheaper to maintain, and develop in the long run. System updates / patches / fixes go live instantly for all users, and all data returned is "live" at all times.
RajeevBhatt wrote: Any other criterion that you might consider important.
You should be asking the customer this.
(By the way, "customer" can also mean "your boss".)
My advice is free, and you may get what you paid for.
|
|
|
|
|
It is very, very rude to post the same question in more than one forum!
For future reference, decide which forum most suits your question and post it there and only there.
In this case either 'General Database' or 'Design and Architecture' would seem most appropriate.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|