VB problem line.

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
I have a problem line in my code, to my reckoning it should tell me I have paid no more door charges.
The code executes but does not give me a print message.
what is wrong with it?

Option Explicit

Private Sub cmdQUIT_Click()
'Terminate Application
End
End Sub

Private Sub cmdStart_Click()
'Declare required storage
Dim Casinos As Integer
Dim Door_Ch As Currency
Dim Money_Res As Currency
Dim Cash As Currency
Dim Money_Spent As Currency

'ask user to input amount of cash taken out
Cash = InputBox("Please input amount taken ", "Cash to Spend")

Door_Ch = 1 * 6


Casinos = Cash - Door_Ch

'Display output in Pic box
picMessage.Print "Door charges paid ", "£"; (Door_Ch)
picMessage.Print "Amount to spend after charges ", "£"; (Cash - Door_Ch)
picMessage.Print "In each casino he spent in casinos ", "£"; (Casinos / 3)
picMessage.Print "The amount he has left is ", "£"; (Cash - 6) Mod 3
If (Cash - 6) Mod 3 >= 2 Then
picMessage.Print "He can visit one more Casino "
If (Cash - 6) Mod 3 = 2 Then
picMessage.Print "He has paid £2 more in door charges "[PROBLEM]
ElseIf (Cash - 6) Mod 3< 2 Then
picMessage.Print "He pays no more door charges "[/PROBLEM]

End If
End If

End Sub
This message was edited by Charlie on 2002-10-28 08:12
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
The cash taken is user defined variable.
The expected results are either £0 £1 £2 change after visting the 3 casinos £2 means he can pay 1 more door charge less than 2 means he has no more door charges to pay.
The **** thing should work Andrew.
Say if I take £28, I have left £1 meaning I do not pay any more door charges.
My code should then print "No more door charges "
Charlie
This message was edited by Charlie on 2002-10-28 08:49
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Conditions 2 and 3 will never be true because they are inside the statement:

If (Cash - 6) Mod 3 >= 2 Then

Your code should be:

Code:
If (Cash - 6) Mod 3 >= 2 Then 
   picMessage.Print "He can visit one more Casino " 
ElseIf (Cash - 6) Mod 3 = 2 Then 
   picMessage.Print "He has paid £2 more in door charges "[PROBLEM] 
ElseIf (Cash - 6) Mod 3 < 2 Then 
   picMessage.Print "He pays no more door charges "[/PROBLEM] 
End If

Remove the second End If.
 

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
Thankyou Andrew,theres a pint at my local with your name on it mate :)

Charlie
 

Forum statistics

Threads
1,143,613
Messages
5,719,708
Members
422,242
Latest member
hishamkhatri

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