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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
L

Legacy 98055

Guest
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
 

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
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

"
 

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
I did it but I still really dont understand how it found my amount spent.

Charlie
 

Forum statistics

Threads
1,144,148
Messages
5,722,791
Members
422,458
Latest member
Muirzy

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
Top