CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Join Date
    Jan 2002
    Posts
    2

    VB 6.0 collge help

    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.

    Thanks again,
    MsTee


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: VB 6.0 collge help

    I'm willing to have a look

    Tom Cannaerts
    slisse@planetinternet.be.remove.this.bit
    Moderator on http://www.vbcodelibrary.co.uk/board

    A bottomless pit, I'm sure it came with the place, who would dig one on purpose?
    Tom Cannaerts
    email: cakkie@cakkie.be.remove.this.bit
    www.tom.be (dutch site)

  3. #3
    Join Date
    Jan 2002
    Posts
    2

    Re: VB 6.0 collge help

    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.



  4. #4
    Join Date
    Jan 2002
    Posts
    63

    Re: VB 6.0 collge help

    2.4 answer:

    Private Sub cmdButton1_GotFocus()
    txBox.Text = "Button Pressed"
    End Sub

    2.5 answer:

    Private Sub cmdButton1_GotFocus()
    txBox2 = txBox1
    End Sub

    Private Sub cmdButton2_Click()
    txBox1 = txBox2
    End Sub


    halforc


  5. #5
    Join Date
    Aug 2000
    Location
    Ottawa, Canada
    Posts
    469

    2.6


    private Sub Text1_GotFocus()
    Text2.FontBold = false
    Text1.FontBold = true
    End Sub
    '
    private Sub Text2_GotFocus()
    Text1.FontBold = false
    Text2.FontBold = true
    End Sub





  6. #6
    Join Date
    Nov 2001
    Posts
    4

    Re: VB 6.0 collge help

    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.


  7. #7
    Join Date
    Jan 2008
    Posts
    4

    Re: VB 6.0 collge help

    Hi

    I'VE JUST FINISHED THE ACTIVITIES BUT STUCK ON 7.7 WITH THE CODING. I CAN'T DO IT.

    PLEASE CAN YOU HELP ME.

    THANKS

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB 6.0 collge help

    you realize this is from 2002?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB 6.0 collge help

    David I guess this is relevant to this thread only. Because the exercise belongs to this thread.

    Zobi,
    Easiest thing to do is write down the steps on the paper first and then try to write the code for the same steps.

  10. #10
    Join Date
    Jan 2008
    Posts
    4

    Re: VB 6.0 collge help

    Does Anyone Know How To Write 2.5 Billion In Vb, Its Not Working, Very Confused

  11. #11
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB 6.0 collge help

    Quote Originally Posted by zobi316
    Does Anyone Know How To Write 2.5 Billion In Vb, Its Not Working, Very Confused
    How are you writing it? Show us the code. In case you are using integer or long then you should change it to double.

  12. #12
    Join Date
    Jan 2008
    Posts
    4

    Re: VB 6.0 collge help

    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

    Do
    population = InputBox("What is the population?", "Population")


    If (population > 6.5) Then
    Do
    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)
    End If
    picOutput.Print (overall population)."
    picOutput.Print "Total population: "; Format(population, "Currency")
    Loop
    End Sub

  13. #13
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB 6.0 collge help

    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.

  14. #14
    Join Date
    Jan 2008
    Posts
    4

    Re: VB 6.0 collge help

    HOPE ITS RIGHT NOW, TOOK ME QUITE LENGTH OF TIME

    Dim Population As Single
    Dim growthRate As Single

    Population = 6.2
    growthRate = 1.2

    Population = Population + (Population * growthRate)

    Do
    Loop Until (Population > 1000000000)

    lstName.AddItem Now & message

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB 6.0 collge help

    Missed a few things, including zero's and the year!

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Dim Population As Single
    Dim growthRate As Single
    Dim Year As Single
    
    Population = 6.2
    growthRate = 0.012
    Year = 2002
    
    Do
      Population = Population + (Population * growthRate)
       Year = Year + 1
    Loop Until (Population > 10)
    
    MsgBox (Int(Population) & " Billion in year: " & Year)
    
    End Sub
    btw - where is this used for? got a link?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured