VB6:- Some help required [message #440936] |
Mon, 06 December 2010 12:16 |
|
Hypnos
Messages: 683 Registered: August 2009 Location: Scotland
Karma:
|
Colonel |
|
|
Well, I'm not too sure how many of you know Visual Basic 6 as a high level language, and my time using it in the past was pretty slim (enough to get me through high school). So, my cousin phoned me up saying he was having some problems with his coursework this year for computing.
I've had a bash at it; and got pretty far with it except for one particular part (see Option 3)
This is the task he has been set out to do.
Quote: | Extremegraph sells high performance graphics cards and computer games online. It wants to develop software that will generate customer codes and let these customers query the details of the graphics cards stored on the system.
How the program should work
The program should:
Initialise the graphics card test data by a suitable method
Generate and display a customer code:
• ask for the forename and surname of the customer
• create the code for the customers by:
• extracting the first letter of each name and add these to the code
• adding a random number between 0 and 9
• adding a random lower case character (a to z)
• display the generated customer code
Answer a number of queries until the customer chooses to exit
• display options and get a choice from the user
• if the choice is 1, ask the customer for a minimum clock speed and display the number of cards that exceed this speed
• if the choice is 2, find and display the name of the graphics card with the highest processor clock speed
• if the choice is 3, ask the customer for a minimum size of RAM and a maximum cost, then display the details of all cards that match these requirements
• if the choice is 4, exit the query session
Display a suitable closing message using the customer name and code
|
The SQA (Scottish Qualifications Authority) had also issued Test Data along side this coursework, which is.
Quick apology for the test data in image format, this was ripped straight from a PDF file, and the table can not be copied into these forums.
For those of you that would like it in text format:-
Quote: | Name
RAM Capacity in Gigabytes
Clock Speed in MHz
Cost in £
RadeonX2
1
1986
187
GeForce95
1
550
41
VaporX
2
870
150
AsusOX2
2
790
354
Nvidia42X
3
1600
575
|
And, as always, here is an example Output.
Quote: | Output
The Output from your program should look something like this:
Erin McKenzie your order code is EM5f
Customer options are:
1 to find how many are fast enough
2 to know which is the fastest
3 to see which is large enough but still affordable
4 to end the session
Please enter your choice . . .
There are 3 cards with clock speeds greater than 800 MHz.
The card with the highest clock speed is the RadeonX2.
The cards matching your search are:
Name
RAM Capacity
Clock Speed
Cost in £
VaporX
2
870
150
AsusOX2
2
790
354
Goodbye Erin and thank you for using Extremegraph.
Remember to quote your customer code (EM5f) in any correspondence.
|
So, here is what I have got so far:-
'--------------------------------------------------------------------------
'Extreme Graph Application, Higher Computing Coursework (2010 - 2011)
'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
'List of Commands
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' cmdStart (Takes the initial input of forename and surname to proceed onto creating customer code.)
' cmdProceed (Prompts user to insert option number between 1 and 4 and initiates desired option.)
' cmdReset (Resets the program to its initial state.)
' cmdExit (Exits the application.)
'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
'List of functions
'--------------------------------------------------------------------------
' InsertNames (Prompts user for input of forename and surname.)
' RandomLetter (Generates the random letter for customer code)
' RandomNumber (Generates the random number for customer code)
' DisplayCode (Displays the user's customer code.)
' ListOptions (Displays the options for the user.)
' Information (Contains all information regarding the graphics cards.)
' OptionOne (Initialises Option One. (Displays how many cards meet specified requirement.))
' OptionTwo (Initialises Option Two. (Displays the graphics card with the fastest clock speed.))
' OptionThree (Initialises Option Three. (Prompts user for input of Minimum RAM and Minimum Cost then displays the cards which meet specification.))
' OptionFour (Initialises Option Four. (Displays forename, customer code and ends query session.))
'--------------------------------------------------------------------------
'--------------------------------------------------------------------------
'Global Variables
'Declaration of Variables
'--------------------------------------------------------------------------
Option Explicit
Dim forename As String
Dim surname As String
Dim number As Integer
Dim AsciiDecimal As String
Dim CharacterAscii As String
Dim random As Integer
Dim graphics_card(5) As String
Dim capacity(5) As Integer
Dim clock_speed(5) As Integer
Dim cost(5) As Integer
Dim index As Integer
Dim InsertClockSpeed As Integer
Dim InsertOption As Integer
Dim MinimumRAM As Integer
Dim MaximumCost As Integer
'--------------------------------------------------------------------------
Private Sub cmdStart_Click()
picdisplay.Cls
Call InsertNames
Call RandomLetter(True)
Call RandomNumber(True)
Call DisplayCode
End Sub
Private Function InsertNames()
forename = InputBox("Please enter your forename.")
surname = InputBox("Please enter your surname.")
End Function
Private Function RandomLetter(Letters As Boolean)
'Private Function to create the random letter used in generating the user's customer code.
Randomize
AsciiDecimal = Abs(Int(97 - 122) * Rnd - 97)
CharacterAscii = Chr(AsciiDecimal)
End Function
Private Function RandomNumber(Numbers As Boolean)
'Private Function to create the random number used in generating the user's customer code.
Randomize
number = Int(Rnd * 10)
End Function
Private Function DisplayCode()
'Private Function to display the user's customer code.
picdisplay.Print "Hello"; Tab(7); forename; Tab(11); surname; "."; Tab(23); "Your order code is:"; Tab(42); Left$(forename, 1); Left$(surname, 1); number & CharacterAscii;
Call ListOptions
End Function
Private Function ListOptions()
'Private Function used to list the customer's options.
picdisplay.Print
picdisplay.Print "You now have four customer options to choose from!"
picdisplay.Print
picdisplay.Print "1) To establish how many graphics cards are fast enough."
picdisplay.Print "2) To establish which graphics card is the fastest."
picdisplay.Print "3) To investigate which cards fit your required size and budget."
picdisplay.Print "4) To exit the program."
picdisplay.Print
picdisplay.Print "Once you have decided which option you wish to proceed with, please click the 'Proceed' button."
End Function
Private Function Information()
For index = 1 To 5
graphics_card(1) = "RadeonX2"
graphics_card(2) = "GeForce95"
graphics_card(3) = "VaporX"
graphics_card(4) = "AsusOX2"
graphics_card(5) = "Nvidia42X"
capacity(1) = "1"
capacity(2) = "1"
capacity(3) = "2"
capacity(4) = "2"
capacity(5) = "3"
clock_speed(1) = "1986"
clock_speed(2) = "550"
clock_speed(3) = "870"
clock_speed(4) = "790"
clock_speed(5) = "1600"
cost(1) = "187"
cost(2) = "41"
cost(3) = "150"
cost(4) = "354"
cost(5) = "575"
Next
End Function
Private Function OptionOne()
InsertClockSpeed = InputBox("Please enter a clockspeed between 0 and 1986")
picdisplay.Print
Select Case InsertClockSpeed
Case Is < 550
picdisplay.Print "There are five or more graphics card with a clockspeed of or greater than " & InsertClockSpeed
Case Is < 790
picdisplay.Print "There are four or more graphics card with a clockspeed of or greater than " & InsertClockSpeed
Case Is < 870
picdisplay.Print "There are three or more graphics card with a clockspeed of or greater than " & InsertClockSpeed
Case Is < 1600
picdisplay.Print "There are two or more graphics cards with a clockspeed of or greater than " & InsertClockSpeed
Case Is <= 1986
picdisplay.Print "There is one graphics card with a clockspeed of or greater than " & InsertClockSpeed
Case Else
MsgBox ("There are no computers with a clock speed greater than 1986, please try again")
End Select
End Function
Private Function OptionTwo()
picdisplay.Print
picdisplay.Print "The graphics card with the highest clockspeed is:"; Tab(49); graphics_card(1); Tab(60); "with a clockspeed of"; Tab(80); clock_speed(1); "."
End Function
Private Function OptionFour()
picdisplay.Print
picdisplay.Print "Goodbye"; Tab(10); forename; Tab(14); "and thankyou for using Extreme Graph!"; Tab(1);
picdisplay.Print "Don't forget your customer code"; Tab(32); Left$(forename, 1); Left$(surname, 1); number & CharacterAscii; "!";
picdisplay.Print
picdisplay.Print "To close this application, please click the 'Exit' button."
End Function
Private Sub cmdProceed_Click()
InsertOption = InputBox("Please enter your option choice in the form of numbers between 1 and 4")
If InsertOption = "1" Then
Call OptionOne
End If
If InsertOption = "2" Then
Call Information
Call OptionTwo
End If
If InsertOption = "3" Then
Call OptionThree
End If
If InsertOption = "4" Then
Call OptionFour
End If
End Sub
Private Sub cmdExit_Click()
'Exit Button
Dim reply As String
reply = MsgBox("You are now exiting Extreme Graph. Are you sure you want to exit?", vbQuestion + vbYesNo)
If reply = vbYes Then
MsgBox ("Thank you for using Extreme Graph. Please come back soon!")
End
End If
End Sub
Private Sub cmdReset_Click()
'Reset Command used to set the application back to initial state.
picdisplay.Cls
picdisplay.Print "Thank you for using this application, to restart this application, simply click the Initiate button."
End Sub
As you can see, I haven't created a Private Function called OptionThree, simply because I don't have much of an idea what to do for it. I know I'll have to use a Find Minimum and Find Maximum algorithm collaborated; but how to do that practically is where I'm at a loss.
Any help with this would be greatly appreciated.
Regards, Hypnos
Caveman wrote on Fri, 21 January 2011 08:26 | Well this topic is still going on. I have to say I haven't watched much Anime recently (maybe a year or so) the last thing I saw was GITS (for the third time)
Im not too sure whether I just dont enjoy Anime anymore or whether its just I dont have time really to shit and watch it.
|
|
|
|