Happy new Year Everyone! I am currently a 2 year ISM major and I am having trouble answering 9 exercise questions. These questions are very short and simple but for an advance programmer but extremely difficult to me. I need help writing these simple textbook generic codes. If anyone can help me I would greatly appreciate it. I have then on file and the can be emailed for review upon request.
First, let me thank you for responding so quickly. Any help you can offer will be greatly appreciated. The following are the exercises that are giving me much difficulty:
2.4 You have a form with a text box, txBox, and a command button, cmdButton1. Write instructions such that when the button is selected, the words “Button Pressed” appear in the text box.
2.5 You have a form with two text boxes, txtBox1 and txtBox2, and two command buttons, cmdButton1 and cmdButton2. Write the instructions such that when cmdButton1 is selected, the contents of txtBox1 are copied to txtBox2, and when cmdButton2 is pressed, the contents of txtBox2 are copied in txtBox1.
2.6 You have a form with two text boxes, txtBox1 and txtBox2. Write the instructions such that the text box with focus has bold text, and the text box without focus has normal (not bold) text.
2.7 You have a picture box, picOutput, and command button, cmdCompute. Write the instructions such that when cmdCompute is selected, the answer to the following problem is displayed: “If 30 people eat 45 hamburgers, how many hamburgers will 50 people eat?”
2.8 You have a form with three boxes, txtBox1, txtBox2 and txtOutput, and a command button, cmdCompute. Write instructions such that when the button is selected, the numerical values in txtBox1 and txtBox2 are multiplied together and the result is displayed in txtOutput.
2.9 You have a form with three text boxes, txtBox1, txtBox2 and txtOutput, and a command button cmdCompute. Write the instructions such that when the button is selected, the strings in tctBox1 and txtBox2 are concentrated and the results is displayed in txtOutput.
2.10 You have a form with a text box, txtBox, a label, lblOutout, and a command button, cmdbutton, cmdCompute. Write the instructions such that the user can enter a value in the text box representing an amount of money, click on the button, and then the label displays the amount of money that would be earned in three years of compound interest at 5%.
3.6 Write a program that reads three strings from a data file and displays the first three letters of each string.
4.5 You have a command button, cmdShowerLength, and two text boxes, txtInput and txtDisplay. Write code such that when cmdShowerLength is clicked, txtDisplay shows the number of characters in the txtInput. The output in txtDisplay should be produced by a call to Sub procedure named Length.
4.6 You have a command button, cmdShow, and a picture box, picOutput. Write Sub procedure, called Doubler, that takes a parameter and doubles it. Use this Sub to write code such that when cmdShow is clicked, the first four powers of 2 ( that is 2,4,8,16) are displayed in picOutput.
5.5 Write a function that takes a number of years and returns the equivalent number of months. Write another function that takes a number of years and returns the equivalent numbers of days (ignore the possibly of leap years). Combine these functions in a program that has a text box, a command button, and a picture box. When the command button is clicked, the number of years in the text box is converted to months and days and displayed in the picture box.
6.5 Suppose, in a certain country, income tax is computed as follows: 18% of income, with a minimum of $1,000. Write a program that takes an income as input and produces the tax amount as output.
6.6 Suppose the country in the previous question modifies its income tax law. People earning less than $35,000 pay the same as before, 18% with a minimum of $1,000. However, people earning $35,000 or more now pay $6,800 + 25% of the income over $35,000. Modify your previous program to account for this change.
6.7 Write a program that makes an abbreviation from the following list of computer terms, and displays the full term. Make use of the Select-Case.
CS Computer Science
CD Compact Disc
DTP Desktop Publishing
OCR Optical Character Recognition
7.7 Suppose the population of a certain country was 125,000 at the beginning of the year 1995. The population is growing at a rate of 4.3% per year. Write a program that determines in what year the population will reach or exceed 200,000.
7.8 Write a program that receives an initial amount, a percentage of yearly compound interest, and a number of years, and then computes how much money would e in the account after that number of years. Make use of a For loop in your calculations.
8.4 Write a Sub called AddTitle that takes an array of Strings as a parameter and, for each String, adds the prefix “Dr”. Use Lbound and Ubound so that your SUB works on any size array. Write a test program for your Sub that crates an array of the following strings, calls the Sub, and then displays the results.
“Kildar”, “Zhivago”, “Spocks”, “Roberts”
8.5 You have a form with a control array of four text boxes, txtInput, a command button, cmdAverage, and a label, lblAverage. Write code such that when cmdAverage is clicked, lblAverage is displays the average of the numbers in the four text boxes. Use a loop in performing the calculation.
I strongly believe that this excersize should be done by the student himself.
It is not fair to answer these questions as that wouldn't help the student. These are very fundamental questions in VB and answering them should be very easy for one who had attended a week lab or went through first few chapters in any VB book.
THIS IS THE THE PROGRAM ""The worlds population reached 6.2 billion people in 2002 and was growing at rate 1.2 percent each year. Assuming the population will continue to grow at the same rate, write a program to determine when the population will exceed 10 billion.
NOT SURE IF THE CODES RIGHT BUT I'M TRYING TO SOLVE IT. PLEASE CHECK
Dim population As Double, quantity As Integer
Dim perform As Integer
Dim message As String
population = InputBox("What is the population?", "Population")
If (population > 6.5) Then
perform = "6.5 * 2400"
message = PMESSAGE & Format(population, "currency")
quantity = CInt(InputBox(message, "Enter population after 6.5 billion"))
If (population >= 6.5) Then
Loop Until (population > 6.5)
picOutput.Print (overall population)."
picOutput.Print "Total population: "; Format(population, "Currency")
Look at your code, The do loops are not valid and what is the need of If condition?
Important Steps to note are these:
1. CurrentPopulation will be added by 1.2% and year will be incremented by 1.
There is no need of Inputbox. Just write a loop that will calculate what the population should be each year and then show the year when the population is greater than 10 Billion. My guess would be somewhere around 2043 so that should be your answer.
Use [code]your code here[/code] tags when you post source code
Search here before you post your question, someone might have already asked it before. My Articles
Missed a few things, including zero's and the year!
Private Sub Form_Load()
Dim Population As Single
Dim growthRate As Single
Dim Year As Single
Population = 6.2
growthRate = 0.012
Year = 2002
Population = Population + (Population * growthRate)
Year = Year + 1
Loop Until (Population > 10)
MsgBox (Int(Population) & " Billion in year: " & Year)