View Single Post
Old 05-17-2004, 08:22 AM  
bobosoft
Confirmed User
 
Join Date: Mar 2003
Posts: 152
for VB 6.0 thats an easy one.

the replace function is laid out like this

Replace(expression, find, replacewith[, start[, count[, compare]]])


you have the first three required operators but you omitted the optional operators

start is the place in the string to start looking for words to replace. the first character is default.

count is the important one, it is the number of replacement to make. the defaul is -1 which meams make as many replacements as possible. simply change the value to 1 and it will only make 1 replacement at a time.

your code would look something like this for 3 replacements

Dim i as integer
For i = 1 to 3

RANDOMWORD = RanddomwordFunction()
document = Replace(document, "(WORD)", RANDOMWORD,1,1)

Next i
or if you wanted to unlimited replacements you oudl have it loop until document is the same as it waqs when it started

do

Document2 = document
RANDOMWORD = RanddomwordFunction()
document = Replace(document, "(WORD)", RANDOMWORD,1,1)

loop until document = document2
bobosoft is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote