VB help please

Charlie

Board Regular
Joined
Mar 1, 2002
Messages
134
hi,
Can some bright person point out to me what I am doing wrong in this code.
I am looking to calculate the cost in £pounds and pence, if the charge for a printout is 5p (Pence) per copy for the first 50,and 3p(Pence) per copy for each additional copy.What am I doing wrong here?

Thanx
Charlie
Private Sub cmdCalculate_Click()
'Declare required storage
Dim Copies As Integer
Dim Charge As Currency

'Invite user how many copies
Copies = InputBox("Please input amount of copies required ", "Copies")

If Copies <= 50 Then
Charge = Copies * 5
ElseIf Copies > 50 Then
Charge = Copies * 5 * 3
End If
'Output total cost in message box
picMessage.Print "The total amount owed is " & Charge; "p"


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Delete the semi-colon that is after "Charge" on your print line.

You also don't need to declare the "Charge" as currency datatype. You really only need an integer there, maybe make it a double, in case someone orders 7000 copies to be made.
 
Upvote 0
Hi Charlie.
<pre>
If Copies <= 50 Then
Charge = Copies * 5
ElseIf Copies > 50 Then
Charge = (50 * 5) + ((Copies-50)*3)
End If
</pre>

Tom
 
Upvote 0

Forum statistics

Threads
1,221,446
Messages
6,159,917
Members
451,603
Latest member
SWahl

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