Private Sub cmdbutton_Click()

Dim population As Single

picWhen.Cls

pop = 6000000

yr = 1999

Do pop > 10000000

picWhen.Print "In"; yr; "Population will be"; pop;

pop = pop * 0.00014

Loop

End Sub

Please tell me the write way to write this

It looks like you're new here. If you want to get involved, click one of these buttons!

- 140.8K All Categories
- 103.6K Programming Languages
- 6.4K Assembler Developer
- 401 Assembly Code Share
- 239 Getting started in assembly
- 4.6K x86 Assembly
- 1.9K Basic
- 97 Qbasic
- 39.9K C and C++
- 5.6K Beginner C/C++
- 330 C/C++ on Linux/Unix
- 450 C/C++ Windows API
- 522 C++ Builder
- 253 C++ Game Development
- 3.3K C++ MFC
- 103 C++.NET
- 404 Visual C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 334 Advanced Delphi
- 360 Delphi beginners
- 4 Haskell
- 9.7K Java
- 56 Enterprise JavaBeans
- 1.3K Java Beginners
- 304 Java Server Pages
- 4.1K Pascal
- 1.3K Perl
- 11 Perl 6
- 2K PHP
- 546 Python
- 37 Ruby
- 4.4K VB.NET
- 258 Advanced VB.Net
- 1.6K VBA
- 20.9K Visual Basic
- 767 Access databases and VB
- 831 Advance Visual Basic
- 1.2K Beginner VB
- 2.6K Game programming
- 315 Console programming
- 90 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 279 3D Graphics
- 129 DirectX
- 125 OpenGL
- 740 Computer Hardware
- 9 Cooling & Overclocking
- 3.4K Database & SQL
- 1.1K Access
- 91 ADO Programming
- 288 MySQL
- 358 Oracle
- 440 SQL-Server
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 25 DirectSound
- 257 XML Development
- 3.3K Classifieds
- 200 Co-operative Projects
- 198 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 603 Jobs Wanted
- 209 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 22 .NET WEB-Services
- 129 .NET WinForms
- 14 .NET XML
- 50 ADO.NET
- 142 C# & VB.NET School Support
- 3.4K Miscellaneous
- 4 Join the Team
- 354 Comments on this site
- 69 Computer Emulators
- 2.1K General programming
- 187 New programming languages
- 621 Off topic board
- 200 Mobile & Wireless
- 72 Android
- 126 Palm Pilot
- 338 Multimedia
- 154 Demo programming
- 184 MP3 programming
- 0 Bash scripts
- 27 Cloud Computing
- 1 Witsbits Go Cloud
- 53 FreeBSD
- 1.7K LINUX programming
- 1 Awk scripting
- 332 Linux Support
- 0 Sed scripting
- 370 MS-DOS
- 0 Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 177 COM/DCOM
- 61 Networking And Security
- 17 Windows 2003 Server
- 6 Windows Vista
- 176 Windows XP
- 940 Software Development
- 417 Algorithms
- 68 Object Orientation
- 24 RUP & UML
- 91 Project Management
- 95 Quality & Testing
- 268 Security
- 63 Evil Scripting
- 81 Hacking
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 61 AJAX
- 4 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 131 Mobile Internet & Messaging
- 211 Wireless development
- 2.2K JavaScript
- 37 JQuery
- 304 WEB Servers
- 153 Apache
- 79 IIS
- 150 WEB-Services / SOAP

## Comments

:

: Private Sub cmdbutton_Click()

: Dim population As Single

: picWhen.Cls

: pop = 6000000

: yr = 1999

: Do pop > 10000000

: picWhen.Print "In"; yr; "Population will be"; pop;

: pop = pop * 0.00014

: Loop

: End Sub

:

:

: Please tell me the write way to write this

:

I wont give you the actual code, but I will give you some hints on how to solve the problem ...

1. Since the start population and target destination is divisible by ten, you can scale down the numbers by chopping off an equal amount of zeros from each number. For instance, use the number 6 and 10 instead of 6 billion and 10 billion. Other numbers that will work are ...

60 and 100

600 and 1000

6000 and 10000

No matter which number combination above, you will get the same result in the long run.

2. %1.4 is really 0.014. If you remember your basic math, your really dividing 1.4 by 100 or moving the decimal two places to the left.

3. Then basically you need to build some kind of loop which adds %1.4 percent to the current population for each iteration, until the population is greater-than equal to the target population. With each iteration of the loop, you are basically going to add one to the year.

4. You need to work with visual basic data types that can store numbers with decimals.

Dim pop As Single

picWhen.Cls

pop = 6

Year = 0

Do While pop >= 10

picWhen.Print "In"; Year; "Population will be"; pop;

pop = pop * 0.00014

Year = Year + 1

Loop

End Sub

I changed everything. I'm getting an error Argument not optional.

: : The world population reached 6 billion people in 1999 and was growing at the rate of 1.4 percent each year. Assuming that the population will continue to grow @ the same rate, write a program to determine when the population will exceed 10 billion.

: :

: : Private Sub cmdbutton_Click()

: : Dim population As Single

: : picWhen.Cls

: : pop = 6000000

: : yr = 1999

: : Do pop > 10000000

: : picWhen.Print "In"; yr; "Population will be"; pop;

: : pop = pop * 0.00014

: : Loop

: : End Sub

: :

: :

: : Please tell me the write way to write this

: :

:

: I wont give you the actual code, but I will give you some hints on how to solve the problem ...

:

: 1. Since the start population and target destination is divisible by ten, you can scale down the numbers by chopping off an equal amount of zeros from each number. For instance, use the number 6 and 10 instead of 6 billion and 10 billion. Other numbers that will work are ...

:

: 60 and 100

: 600 and 1000

: 6000 and 10000

:

: No matter which number combination above, you will get the same result in the long run.

:

: 2. %1.4 is really 0.014. If you remember your basic math, your really dividing 1.4 by 100 or moving the decimal two places to the left.

:

: 3. Then basically you need to build some kind of loop which adds %1.4 percent to the current population for each iteration, until the population is greater-than equal to the target population. With each iteration of the loop, you are basically going to add one to the year.

:

: 4. You need to work with visual basic data types that can store numbers with decimals.

:

:

:

:

Other problems you will have:

1. You have an infinite loop (you do not have a proper stop condition)

2. You should be calling the Print function after the loop

3. Your decimal for the percent is wrong (look in my last response)

4. The year variable should be initialized to the year 1999

5. In the loop, you are not properly adding a percentage of the population ... this line is wrong ...

[code]

pop = pop * 0.00014

[/code]

Not only is the decimal wrong, you are essentially storing the value of the "pop" variable multiplied by the decimal and overwritting "pop".

This basically means that, after the first loop "pop" will equal

0.084 because of (6 * 0.014) when it ...

should equal 6.084 (6 + (6 * 0.014))

You need to rewrite this expression to add the value of "pop" times the decimal to the current value of "pop".

: Private Sub cmdbutton_Click()

: Dim pop As Single

: picWhen.Cls

: pop = 6

: Year = 0

: Do While pop >= 10

: picWhen.Print "In"; Year; "Population will be"; pop;

: pop = pop * 0.00014

: Year = Year + 1

: Loop

: End Sub

: I changed everything. I'm getting an error Argument not optional.

:

: : : The world population reached 6 billion people in 1999 and was growing at the rate of 1.4 percent each year. Assuming that the population will continue to grow @ the same rate, write a program to determine when the population will exceed 10 billion.

: : :

: : : Private Sub cmdbutton_Click()

: : : Dim population As Single

: : : picWhen.Cls

: : : pop = 6000000

: : : yr = 1999

: : : Do pop > 10000000

: : : picWhen.Print "In"; yr; "Population will be"; pop;

: : : pop = pop * 0.00014

: : : Loop

: : : End Sub

: : :

: : :

: : : Please tell me the write way to write this

: : :

: :

: : I wont give you the actual code, but I will give you some hints on how to solve the problem ...

: :

: : 1. Since the start population and target destination is divisible by ten, you can scale down the numbers by chopping off an equal amount of zeros from each number. For instance, use the number 6 and 10 instead of 6 billion and 10 billion. Other numbers that will work are ...

: :

: : 60 and 100

: : 600 and 1000

: : 6000 and 10000

: :

: : No matter which number combination above, you will get the same result in the long run.

: :

: : 2. %1.4 is really 0.014. If you remember your basic math, your really dividing 1.4 by 100 or moving the decimal two places to the left.

: :

: : 3. Then basically you need to build some kind of loop which adds %1.4 percent to the current population for each iteration, until the population is greater-than equal to the target population. With each iteration of the loop, you are basically going to add one to the year.

: :

: : 4. You need to work with visual basic data types that can store numbers with decimals.

: :

: :

: :

: :

:

:

:

: Other problems you will have:

:

: 1. You have an infinite loop (you do not have a proper stop condition)

: 2. You should be calling the Print function after the loop

: 3. Your decimal for the percent is wrong (look in my last response)

: 4. The year variable should be initialized to the year 1999

: 5. In the loop, you are not properly adding a percentage of the population ... this line is wrong ...

:

: [code]

: pop = pop * 0.00014

: [/code]

:

: Not only is the decimal wrong, you are essentially storing the value of the "pop" variable multiplied by the decimal and overwritting "pop".

:

: This basically means that, after the first loop "pop" will equal

:

: 0.084 because of (6 * 0.014) when it ...

: should equal 6.084 (6 + (6 * 0.014))

:

: You need to rewrite this expression to add the value of "pop" times the decimal to the current value of "pop".

:

Which is quite basic math actually: The population grows 1.4% per year. So added is the 1.4% * population. Which would equal: Pop + Pop * 0.014

This can be rewritten if you like: Pop * 1.014

The 1.014 means a total population of 101.4% relative to the last year.

Good luck

Greets...

Richard