Hi,

I have to write a function in Visual Basic within Microsoft that takes customer type and number of books purchased as inputs and returns the discount that should be given. Calculate the total sum after deducting discount that is to be paid and that the interface shows the total amount before and after the discount.

I would like to get some help in this because im totally stuck. I have designed the form in VB somewhat,not finalised ofcourse and done the code. But I can't manage to get it working as how it's described above :S Pleaseeeeeee helppppppppppppppppppp.

I have attached the file of what I did so far.

Thanks

I'm not sure in excell, but the basics will be VERY similar. I am working on a customer type of "Individual". Try the following -

``````Dim u As Integer
Dim v As Integer
Dim w As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer

x = Val(AndYourQuantityValue) 'Yours looks like a combo box (cmbQuantity)
z = Val(AndYourDiscountValue) 'As per your function

u = (y * z)/100
v = y - u

w = v 'Your Total Price After Discount
'You can here use w to work quantity etc.``````

hey, thanks

but am still confused :S Let's say I select customer type individual in the form, then i select that the individual customer is buying 25 books so the discount will then be 25%. So my question is how can I get the discount of 25 % as an output which will then calculate the total amount of the price? I don't even know if am making sense here but hope you can help me out.

thanks

Try the following -

``````Dim u As Integer
Dim v As Integer
Dim w As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer

Dim answer As String 'This is new........

'Lets say that x = 10 (AndYourQuantityValue)
x = Val(10)
'Lets say that y = 15 (AndYourPriceValue)
y = Val(15)
'Then w = the total price WITHOUT discount
w = x * y '10 * 15 = 150

'Lets say that you are giving away 25% discount as per your function
z = Val(25)

'Get the total DISCOUNT amount
u = (w * z)/100 '(150 * 25)/100 = 37.50
'Get the total price to PAY
v = w - u '150 - 37.50 = 112.50

answer = "\$" & " 112.50"``````

This should explain it more in detail.

Try the following -

``````Dim u As Integer
Dim v As Integer
Dim w As Integer
Dim x As Integer
Dim y As Integer
Dim z As Integer

Dim answer As String 'This is new........

'Lets say that x = 10 (AndYourQuantityValue)
x = Val(10)
'Lets say that y = 15 (AndYourPriceValue)
y = Val(15)
'Then w = the total price WITHOUT discount
w = x * y '10 * 15 = 150

'Lets say that you are giving away 25% discount as per your function
z = Val(25)

'Get the total DISCOUNT amount
u = (w * z)/100 '(150 * 25)/100 = 37.50
'Get the total price to PAY
v = w - u '150 - 37.50 = 112.50

answer = "\$" & " 112.50"``````

This should explain it more in detail.

Thanks