Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing prices on a text

Status
Not open for further replies.

hakkatil

ISP
Apr 4, 2003
10
US
I need to replace prices with spaces or delete them that comes from database. Prices can be 2, 3 or 4 digits. For example the line is "this products is $45.99". How can I replace $45.99 with spaces or delete it. The amount can be $123.33 or $.99 or $1.99. Is there an easy way to do that?
 
I am assuming that you are referencing the db value when writing the statement. Is there some criteria for a time when the prices are not to be displayed or is it for everyone?


Bastien

Cat, the other other white meat
 
it is for everyone. This information comes from a shopping cart database. There are many records. Some of these records contains prices. When these reports display on page, I don't want to display prices that in a text.

Say we have 3 records to display on a page.

This product is $49.99.
This products is $19.99 and addition for a color $5.99.
this product is $145.99.

What I want is when those records above diplayed, delete the prices or replace with spaces.

This product is ***.**.
This products is ***.** and addition for a color **.**.
this product is ****.**

 
You store the price attribute separately or is it a text element containing the full string?



Bastien

Cat, the other other white meat
 
use regex to replace the values...

ex...google the net to find more examples
Code:
Dim regEx, str1               ' Create variables.
  str1 = "The quick brown fox jumped over the lazy dog."
  Set regEx = New RegExp            ' Create regular expression.
  regEx.Pattern = patrn            ' Set pattern.
  regEx.IgnoreCase = True            ' Make case insensitive.
  ReplaceTest = regEx.Replace(str1, replStr)   ' Make replacement


Bastien

Cat, the other other white meat
 
Can I use this with different prices? Some prices have 3, some have 4, some have 5 digits.
 
yes

Regex looks for patterns


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top