Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
do you know the formula. assume if I have an input box to allow user to enter an integer between 1 and 10.the input number will double every 18 month. once integer input, the math will perform like this. so far this is what i got but the math does not double every 18 months.
Dim strInputComputerSpeed As String
Dim decInputComputerSpeed As Decimal
Dim decTotalComputerSpeed As Decimal
Dim decYear As Decimal = 1DDo Until decYear > 15
strInputComputerSpeed = Me.txtInput.TextIf IsNumeric(strInputComputerSpeed) Then
decInputComputerSpeed = Convert.ToDecimal(strInputComputerSpeed)
If decInputComputerSpeed > 0 And decInputComputerSpeed <= 10 Then
decTotalComputerSpeed = decInputComputerSpeed + decInputComputerSpeedMe.lstDisplay.Items.Add("After " & decYear & " years, your computer speed will reach " & decTotalComputerSpeed & " GHz")
decYear += 1End If
End If
Loop

It's not really an exact calculation. Off that link I posted, you can see the transistor count since 1971:

i need to know the formula!I know it double every 18 months. I'm trying to write this small application!

There is no precise formula. It is like Murphy's Law or Sod's Law or Godwin's Law even, it is aleatory.
Stuart

here is the formula
T = I * 2
T represent total result. I, represent input variable. and 2 is the double. which mean if user enter 2 as the input the after 1 year, the result will be 4. it work for the first time but I cannot get the loop to repeat this for 15 time. anybody with any advice!

You are resetting decTotalComputerSpeed to the exact same value each time through your loop:
decTotalComputerSpeed = decInputComputerSpeed + decInputComputerSpeedWhat you need to do is have a variable (decTotalComputerSpeed) that is initialized before entry into the loop, and then updated each time INSIDE the loop using the CURRENT value, not the initial value. I won't give you any more clues as that would spoil the fun.

thank for the advice klint. I figure it out. the solution is to move the loop like this and some math problem.
strInputComputerSpeed = Me.txtInput.Text
If IsNumeric(strInputComputerSpeed) Then
decInputComputerSpeed = Convert.ToDecimal(strInputComputerSpeed)
If decInputComputerSpeed > 0 And decInputComputerSpeed < 11 ThenDo Until decYear > 15
dectotalComputerSpeed = decInputComputerSpeed + decInputComputerSpeed
Me.lstDisplay.Items.Add("After " & decYear & " years, your computer speed will reach " & decTotalComputerSpeed & " GHz")decYear += 1
decInputComputerSpeed *= 2End If
End If
Loop

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |