VB6 Question

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
Im looking to make a prog that will find out how much money I had in my pocket when I left the pub and went to the casino.
I paid = £1.00 to get in
I lost half my money there and paid £1.00 to get out.
I then went to a second casino and did the same thing
Paid £1 entry lost half my money,paid £1.00 to get out.
Not learning my lesson I went to a third casino and did it again
paid £1.00 to get in
lost half my remaining cash
and paid another £1.00 to get out.
I was then broke.
I want to find out how much money I started with, I think I gotta use a Do Loop for this but im stuck finding how much I spent.
This message was edited by Charlie on 2002-10-25 07:34
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi Charlie.
There is probably an equation to solve this but I do not know how. This procedure works:
<pre>
Sub SubSub() 'answer is 21
Dim Broke As Currency, StartingCash As Currency, Visits
StartingCash = 6
Do
StartingCash = StartingCash + 0.01
Broke = StartingCash
For Visits = 1 To 3
Broke = Broke - 1
Broke = Broke - (Broke / 2)
Broke = Broke - 1
Next
Loop While Broke <> 0
End Sub
</pre>
Started with 21

Spent 1 = 20
Spend 1/2 = 10
Spend 1 = 9

Spent 1 = 8
Spend 1/2 = 4
Spend 1 = 3

Spent 1 = 2
Spend 1/2 = 1
Spend 1 = 0

Tom
 
Upvote 0
Hiya Tom, I came up with this answer with a lot of help I might add.
Loops are very new to me.

Option Explicit

Private Sub cmdQUIT_Click()
'Terminate Application
End
End Sub

Private Sub cmdStart_Click()
Dim intMyMoney As Integer
Dim intLoop As Integer
Dim intStops As Integer

intStops = 3
intMyMoney = 0
For intLoop = 1 To intStops
intMyMoney = (intMyMoney + 1) * 2 + 1
Next
picMessage.Print "I spent this amount "; "£"; intMyMoney


End Sub

you can tell me if it looks wrong my feelings wont be hurt.
Charlie

"
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top