Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old September 4th, 2003, 05:58 PM
drew010 drew010 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: california usa
Posts: 346 drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 9 h 30 m 50 sec
Reputation Power: 12
Send a message via ICQ to drew010 Send a message via AIM to drew010 Send a message via Yahoo to drew010
Validating Input for new person to vb

hello,
im very new to vb and am making a little program where a user enters a url, i need to be able to validate it, much like a perl regular expression.. does something like this exist in vb? all it needs to do is make sure they have http://(optional www)a hostname and a 3 letter tld. with no file or folder following that.

if someone could show me some code or point me to a tutorial id appreciate it.

Reply With Quote
  #2  
Old September 4th, 2003, 06:06 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,550 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 15 h 43 m 35 sec
Reputation Power: 640
You can add the Microsoft Scripting Runtime to your vb6 project and use the VBScript RegEx object to do RegEx-type validations.

http://msdn.microsoft.com/library/e...vsobjRegExp.asp

Reply With Quote
  #3  
Old September 5th, 2003, 11:28 AM
drew010 drew010 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: california usa
Posts: 346 drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 9 h 30 m 50 sec
Reputation Power: 12
Send a message via ICQ to drew010 Send a message via AIM to drew010 Send a message via Yahoo to drew010
hi, thanks for the article, but I guess I dont have a build in object called regexp or somethign..

the code i put in is:

Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match In Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & vbCrLf
Next
RegExpTest = RetStr
End Function

and when i try to compile it highlights New RegExp on line 3 of the function and says user-defined type is not defined... i guess this means I dont have the regexp objects in my vb version?? im running vb6 enterprise edition and created an enterprise project... any more help or code is appreciated.

i come from c, php, and java so vb still is looking strange and confusing in my second week of it.
thanks

Reply With Quote
  #4  
Old September 5th, 2003, 11:41 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,550 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 15 h 43 m 35 sec
Reputation Power: 640
You have to add a reference in your project to the Microsoft Scripting Runtime. The RegEx object is an object of VB Script, not VB itself.

Reply With Quote
  #5  
Old September 5th, 2003, 08:44 PM
drew010 drew010 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: california usa
Posts: 346 drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 9 h 30 m 50 sec
Reputation Power: 12
Send a message via ICQ to drew010 Send a message via AIM to drew010 Send a message via Yahoo to drew010
ok,, how do i do that?

Reply With Quote
  #6  
Old September 5th, 2003, 11:25 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,550 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 15 h 43 m 35 sec
Reputation Power: 640
If you have VB6, click Project - References and add the scripting runtime.

Reply With Quote
  #7  
Old September 9th, 2003, 08:07 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
OK! It's a good idea!
Thank U to Doug G.

Reply With Quote
  #8  
Old September 13th, 2003, 09:43 PM
drew010 drew010 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: california usa
Posts: 346 drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level)drew010 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 9 h 30 m 50 sec
Reputation Power: 12
Send a message via ICQ to drew010 Send a message via AIM to drew010 Send a message via Yahoo to drew010
Here is an example that I came up with that partially works but fails sometimes..

RegExpTest("^http://+.[a-z0-9.]+.[a-z0-9\-.]+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo| br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|d o|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt| gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|k y|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv| mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro |ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg| th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|z w)$",txtUrl.Text)

sometiems will work but i have a feeling the problem is with the string concatenation in their. im used to perl regular expressions and vb's are a little different, if someone could fix that id appreciate it...

Last edited by drew010 : September 13th, 2003 at 11:02 PM.

Reply With Quote
  #9  
Old September 14th, 2003, 08:37 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
Thumbs up

Hi drew010!
I try your program!It can work!.
but I don't know this statement in the pattern:
^http://+.[a-z0-9.]+.[a-z0-9\-. ]

What's the meaning? To pattern the URL?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Validating Input for new person to vb


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway