replacing string characters with a variable.

jcturp

New member
Joined
Mar 30, 2008
Messages
1
Programming Experience
Beginner
Hello

I have an article that is stored on SQL 2000 table. My vb web application retrieve the article and stored it on a variable.

Article on SQL table:
The quick brown fox jump on the <lazy dog> near the river bank.

I would like to replace the word "<lazy dog>" with the following variable(having a formatting funtion).

Format(decTotalAmount, "#,###.00")


My code can read as below;

strArticle = "The quick brown fox jump on the <lazy dog> near the river bank."
strArticle = strArticle.replace("<Amount>", Format(decTotalAmount, "#,###.00"))


There is no error with such code but I cant get the right result. And the text displayed as
"The quick brown fox jump on the Format(decTotalAmount, "#,###.00") near the river bank."


What I wanted to happen is to treat the Format(decTotalAmount, "#,###.00") as a variable and not as a part of the whole string. Please give me the right direction. Thanks
 
This worked for me:

Dim strArticle As String
Dim decTotalAmount As Decimal
decTotalAmount = 1535.23
strArticle = "The quick brown fox jump on the <lazy dog> near the river bank."
strArticle = strArticle.Replace("<lazy dog>", Format(decTotalAmount, "#,###.00"))
Label1.Text = strArticle


Where Label1 is a label on the webpage.
 
Back
Top