VB6:- Some help required [message #440936] |
Mon, 06 December 2010 12:16 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/24914.png) |
Hypnos
Messages: 683 Registered: August 2009 Location: Scotland
Karma: 0
|
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.
![http://i53.tinypic.com/27wvi3b.png](http://i53.tinypic.com/27wvi3b.png)
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.
![http://i56.tinypic.com/263btjo.png](http://i56.tinypic.com/263btjo.png)
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
![http://i33.tinypic.com/2ls7bzb.png](http://i33.tinypic.com/2ls7bzb.png)
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.
|
|
|
|
Re: VB6:- Some help required [message #440958 is a reply to message #440936] |
Mon, 06 December 2010 14:22 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
|
Your honesty about it being coursework is appreciated, but I must indicate I do not wish to condone cheating. He really should solve this for himself. That being said, I solved the problem, because it was simple, and I'm bored.
Toggle Spoiler
Ok, first of all:
Quote: |
' OptionThree (Initialises Option Three. (Prompts user for input of Minimum RAM and Minimum Cost then displays the cards which meet specification.))
|
Should read, changes bolded:
Quote: |
' OptionThree (Initialises Option Three. (Prompts user for input of Minimum RAM and Maximum Cost then displays the cards which meet specification.))
|
What you need to do for option three is to make a list of all cards that have RAM >= to MinimumRAM and then go through that list, removing all whose cost is > maximum cost. Output the list.
Renguard is a wonderful initiative
Toggle Spoiler
BBC news, quoting... |
Supporters of Proposition 8 will argue California does not discriminate against gays, as the current law allows them to get married - as long as they wed a partner of the opposite sex.
|
halokid wrote on Mon, 11 October 2010 08:46 |
R315r4z0r wrote on Mon, 11 October 2010 15:35 |
![index.php?t=getfile&id=12992&private=0](index.php?t=getfile&id=12992&private=0)
|
the hell is that?
|
|
|
|
|
Re: VB6:- Some help required [message #441437 is a reply to message #440936] |
Mon, 13 December 2010 12:25 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) |
![](http://renegadeforums.com/images/custom_avatars/24914.png) |
Hypnos
Messages: 683 Registered: August 2009 Location: Scotland
Karma: 0
|
Colonel |
|
|
Update: Was a simple typo which you changed in the spoiler.
Here's how I done it.
Toggle Spoiler
Private Sub OptionThree(ByRef cost() As Integer, capacity() As Integer, graphics_card() As String)
'Initialises Option Three. (Prompts user for input of Minimum RAM and Minimum Cost then displays the cards which meet specification.)
Dim MinimumRAM As Integer
Dim MaximumCost As Integer
Call Information
MinimumRAM = InputBox("Please enter a RAM capacity between 1 and 3")
MaximumCost = InputBox("Please enter the maximum cost.")
picdisplay.Print "Graphics Card"; vbTab; "Capacity"; Tab(27); "Clock Speed"; vbTab; "Cost"
For index = 1 To 5
If capacity(index) >= MinimumRAM And cost(index) <= MaximumCost Then
picdisplay.Print
picdisplay.Print graphics_card(index); Tab(17); capacity(index); Tab(27); clock_speed(index); Tab(40); cost(index)
End If
Next
End Sub
I also added passing parameters to make it more efficient.
![http://i33.tinypic.com/2ls7bzb.png](http://i33.tinypic.com/2ls7bzb.png)
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.
|
|
|
|