extract the price from a string

pb21

Registered User.
Local time
Today, 21:04
Joined
Nov 2, 2004
Messages
122
I have a string which is built up with a calculate button and is displayed in a label:
The Price is: £ 985 Per Product

Me.LblCost.Caption = "The Price is: " & "£ " & CStr(Price) & Strpriceduration

this gives me the cost per product, some products are priced per week and I wanted to calculate the total price by multiplying the weekly price. I have a combo with 1 to 20 to allow user to select a multiplier value that I wanted to send the value to a total value text field. (all unbound) I am going then to create a recordset to update a bookings table and also a transactions table where the invoices take their details from.

How do I extract the varying length price from the string above. The multiplier combo change event is where this is looking for the price off the form.

hope I explained that well.

regards in advance and happy may day.
 
Hi

Assuming that you can't get at the Price value which you use in the caption setting (which would be far easier), you could try this:-

txtTotal = cmbMultiplyer * val(mid(Me.LblCost.Caption ,instr(Me.LblCost.Caption,"£")+1)

This will only work if you have a £ sign in the caption, it will take the value from the pound sign onwards and should discard other words after the amount.

Hope that helps

Paul
 
extraction

That is a really great solution thank you
 

Users who are viewing this thread

Back
Top Bottom