Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Validate a URL in a TextBox

Posted on 1999-07-21
5
Medium Priority
?
158 Views
Last Modified: 2010-05-02
I have a textbox where a user needs to type a URL in this format:

http://www.mysite.com

I want to do the following:  First, look at the textbox contents to see if "http://" is in front of the textbox contents, and second, if its not there, add it.

So if the user typed:

mysite.com

It would automatically change to:

http://www.mysite.com

Thanks!
0
Comment
Question by:EvanL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 80 total points
ID: 1526521
use InStr() which does exactly what you want... it will check whether or not the string you give it contains a substr and if so returns true otherwise it returns false..

if you need more help please let me know!

Good Luck!!

..-=ViKtOr=-..
0
 
LVL 1

Author Comment

by:EvanL
ID: 1526522
I'm a newbie, Viktor..  But I did know InStr().

Score me some code, and I'll raise the points and give you and A.

Thanks..
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1526523
ok, hold on for a few minutes :)) VB is on my other comp, and it'd take a few minutes to start up and create a test program :) hehe... in 10 to 30 minutes i[ll be back with the code okay? :)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1526524
I haven't tested the following since I didn't use the other computer...

you can try the LIKE... example..

if not UCase(Text1.Text) Like "HTTP://*" then Text1.Text = "http://" & Text1.Text

if you want to use the InStr() you can do something like this..

if not InStr(1, UCase(Text1.Text), "HTTP://") then Text1.Text = "http://" & Text1.Text

try these two examples and see if they work.. I haven't tested them so please try them out and let me know if they work properly

Good Luck!!

..-=ViKtOr=-..
0
 
LVL 1

Author Comment

by:EvanL
ID: 1526525
Thanks for the help... This solution worked best.  Put this in your textbox.lostfocus event.

if not UCase(Text1.Text) Like "HTTP://*" then Text1.Text = "http://" & Text1.Text


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question