Need Help With Some Visual Basic 6 Code.
DY357LX
Playing since day 1. Still can't Comm.England Join Date: 2002-10-27 Member: 1651Members, Constellation
<div class="IPBDescription">Replacing Characters. Kinda Weird. Help?</div> I need help with some VB6 code. Yes I know VB sucks, blah
blah blah. Onto the request.
Example 1:
=======
If the user was type a URL into the URL bar, any gaps
they typed would be replaced with a dash ("-").
For example,:
www.natural selection.org would come out as
www.natural-selection.org see?
Example 2:
========
Lets say the user inputs the words:
"Hello I Am A Natural Selection Player"
into the text box. I need the output to
be displayed as:
"Hello-I-Am-A-Natural-Selection-Player".
So the spaces would be replaced with dashes.
Someone told me to use the Replace() function but I
don't know how to use it and Google hasn't turned up
anything useful. If you can help, please do so.
Example code would be great and i'll release the
program and source code here when its complete.
(Currently 90% complete, I need this code and some layout
alterations.) If you wish to guide me via PM, X-Fire or MSN
then feel free.
X-Fire: DY357LX
MSN : tylrdiablos-at-hotmail-dot-com
PM : The usual method
telekinesis: Move the pen next to my right speaker
and get it to write the code on notepad provided.
Please help poor DY :-/
blah blah. Onto the request.
Example 1:
=======
If the user was type a URL into the URL bar, any gaps
they typed would be replaced with a dash ("-").
For example,:
www.natural selection.org would come out as
www.natural-selection.org see?
Example 2:
========
Lets say the user inputs the words:
"Hello I Am A Natural Selection Player"
into the text box. I need the output to
be displayed as:
"Hello-I-Am-A-Natural-Selection-Player".
So the spaces would be replaced with dashes.
Someone told me to use the Replace() function but I
don't know how to use it and Google hasn't turned up
anything useful. If you can help, please do so.
Example code would be great and i'll release the
program and source code here when its complete.
(Currently 90% complete, I need this code and some layout
alterations.) If you wish to guide me via PM, X-Fire or MSN
then feel free.
X-Fire: DY357LX
MSN : tylrdiablos-at-hotmail-dot-com
PM : The usual method
telekinesis: Move the pen next to my right speaker
and get it to write the code on notepad provided.
Please help poor DY :-/
Comments
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Replace(-, )<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
EDIT: Err, if you meant that you want to replace spaces with dashes:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Replace( ,-)<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Replace(-, )<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
EDIT: Err, if you meant that you want to replace spaces with dashes:
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Replace( ,-)<!--c2--></td></tr></table><div class='postcolor'><!--ec2--> <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
Nah, it just brings up a bunch of "Expected Expression" errors.
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->Dim x as String;
x = "whatever.url.com/whatever"
x = Replace(x, " ", "-")<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
MSDN online is more up-to-date than the copies which ship with various products (including my old Visual C++ 6)
say that strText = "www.natural-selection.org"
strText = Replace (strText, "-", " ")
you have to format it like so because Replace is a function, thus it returns a value when it's called, which is then placed into strText.
edit: frigging guy with wierd avatar beat me :X
Yes but it takes some form of voodoo I believe.
By like a whole day. :P
The code is working... kinda. Everytime I type a dash
in a textbox the typing cursor goes back to the beginning
of the textbox.
So if I was to type
"www.natural selection.org" it would display as
"selection.orgwww.natural-"
Er... can anyone tell me how to fix that please?
I'm looking through the textbox fields but nothing
seems to indicate this.