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 10-02-2003, 11:25 AM   #1
alexg
IL4L.com
 
Join Date: Aug 2003
Location: Israel - ICQ: 162136565
Posts: 11,287
Visual Basic question

Ok, this shouldn't be a tough one if you're good at VB:
I wrote a function that replaces a certain string in a text with another one.
This is the function:

Public Function ReplaceString(OriginalString As String, StringToRem As String, StringToInsert As String) As String


If InStr(1, OriginalString, StringToRem, 0) > 0 Then
ReplaceString = Left(OriginalString, InStr(1, OriginalString, StringToRem, 0) - 1) & StringToInsert & Right(OriginalString, Len(OriginalString) - Len(StringToRem) - InStr(1, OriginalString, StringToRem, 0) + 1)
Else
ReplaceString = OriginalString
End If
End Function

now, there is a problem with this definition:

Private Sub Command1_Click()
Text1.Text = ReplaceString(Text1.Text, old.Text, new.Text)
End Sub

It works when I write it like this:

Private Sub Command1_Click()
Text1.Text = ReplaceString(Text1.Text, "hi", "hello")
End Sub

In this case, it replaces the string "hi" with "hello", but I want to set both strings in two textboxes. Anyone knows the answer?

Thanks a lot
alexg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-02-2003, 12:13 PM   #2
chadglni
Confirmed User
 
Join Date: Dec 2002
Location: PEI, Canada
Posts: 6,924
It works fine here, sure you have your textbox names right?

As an alternative you could have used the built in Replace() function instead of writing your own.

The Replace function replaces a specified part of a string with another string a specified number of times.

Syntax
Replace(string,find,replacewith[,start[,count[,compare]]])
chadglni is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-02-2003, 02:14 PM   #3
alexg
IL4L.com
 
Join Date: Aug 2003
Location: Israel - ICQ: 162136565
Posts: 11,287
I didn't know there was a pre-built function. Thanks for that.

hmm.. It worked for you? guess I'll check it again and see what's worng..maybe i did make a mistake with the textboxes names.

thanks again
alexg 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.