Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-17-2004, 07:57 AM   #1
More Booze
Confirmed User
 
Join Date: Mar 2004
Posts: 5,116
Visual Basic programmers, Help needed!

I wrote a function which picks a random word from a listbox.
The function is called "RANDOMWORD".

I got a textbox with the text
"Hi I am (WORD). I like to (WORD) and (WORD)."

I want to replace all (WORD) with random words but if
I use
document = Replace(document, "(WORD)", RANDOMWORD)
it will change all (WORD) to the same random word.

How should I do to get a new word for each (WORD) in the textbox?
(In the exeample its only 3 (WORD) but it vary)
More Booze is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 07:59 AM   #2
malakajoe
Confirmed User
 
Join Date: Feb 2003
Location: Sacramento
Posts: 1,751
I am far from a VB expert...but try this maybe.

Build an array first and then insert from that array.

Again, don't know much and probably won't work.
__________________
Selfpleasure.com for sale on auction. Closes on Tuesday March 11th at 9pm PST!!!!

Dirty enough to be good, but clean enough for everyone!
------------------------------------------------------------------

Moral Police - First graduating class coming soon! - Forcing our values across the internet
malakajoe is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:03 AM   #3
NickPapageorgio
Confirmed User
 
Join Date: Apr 2004
Location: NC
Posts: 8,323
I don't know VB but I would imagine it is much like anything else. Build an array of all the different (WORDS) you want and then build a function to randomize those words as needed.
__________________
NickPapageorgio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:07 AM   #4
bobosoft
Confirmed User
 
Join Date: Mar 2003
Posts: 152
Which version of VB is it?
bobosoft is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:12 AM   #5
More Booze
Confirmed User
 
Join Date: Mar 2004
Posts: 5,116
Its Visual Basic 6.0.

I dont know how the array thing could work better, I already can pick random words the problem is that I cant replace (WORD) without use the same random word for all.

Or maby you meant that I could grab the textbox and make it into a array and then loop throu it and replace the words one by one..
Hmm that may work.
More Booze is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:14 AM   #6
NickPapageorgio
Confirmed User
 
Join Date: Apr 2004
Location: NC
Posts: 8,323
I was saying maybe build an array and function for each (WORD) box. So 3 different sets of arrays and functions. But then again I don't know VB so someone with more experience would probably have a better suggestion.
__________________
NickPapageorgio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:22 AM   #7
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
Old 05-17-2004, 08:29 AM   #8
More Booze
Confirmed User
 
Join Date: Mar 2004
Posts: 5,116
YES!!!! thanks alot bobosoft, it fucking WORKED!
I asked about this in 4 programmer forums but nobody could answer.
More Booze is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2004, 08:32 AM   #9
bobosoft
Confirmed User
 
Join Date: Mar 2003
Posts: 152
Quote:
Originally posted by More Booze
YES!!!! thanks alot bobosoft, it fucking WORKED!
I asked about this in 4 programmer forums but nobody could answer.
Of course not, the brightest of the brightest all hang around gfy.
bobosoft is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.