|
|
|
||||
|
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. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
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) |
|
|
|
|
|
#2 |
|
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 |
|
|
|
|
|
#3 |
|
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.
|
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Mar 2003
Posts: 152
|
Which version of VB is it?
|
|
|
|
|
|
#5 |
|
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. |
|
|
|
|
|
#6 |
|
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.
|
|
|
|
|
|
#7 |
|
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 |
|
|
|
|
|
#8 |
|
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. |
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Mar 2003
Posts: 152
|
Quote:
|
|
|
|
|