Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Check if the URL is valid
View previous topic :: View next topic  
Author Message
Khaldoun baz
Newbie


Joined: 12 Aug 2004
Posts: 1

PostPosted: Aug 12th, 2004 05:20 AM    Post subject: Check if the URL is valid Reply with quote

check if the url is valid

[vb:1:0bfb2b5918]Private Const S_FALSE = &H1
Private Const S_OK = &H0
'Only implemented as unicode...
Private Declare Function IsValidURL Lib "URLMON.DLL" (ByVal pbc As Long, ByVal szURL As String, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
MsgBox "Is valid URL: " + CStr(IsGoodURL("http://www.google.com"))
MsgBox "Is valid URL: " + CStr(IsGoodURL("hxxp:/www.googlei.uhoh"))
End Sub
Public Function IsGoodURL(ByVal sURL As String) As Boolean
'The IsValidURL always expects a UNICODE string, but whenever
'VB calls an API function, it converts the strings to ANSI strings.
'That's why we're going to use a trick here. Before calling the function,
'We're going to convert the unicode string to unicode so we get a double
'unicode string.
'Before VB calls the API function, it converts our double unicode string
'to a normal unicode string; exactely what IsValidURL is expecting.
sURL = StrConv(sURL, vbUnicode)
'Now call the function
IsGoodURL = (IsValidURL(ByVal 0&, sURL, 0) = S_OK)
End Function[/vb:1:0bfb2b5918]
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 12th, 2004 05:29 AM    Post subject: Reply with quote

Hi Khaldoun baz,

What is the problem with this ? Can you please explain ?

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Andir
Centurion


Joined: 21 Dec 2003
Posts: 184
Location: Chicago Area

PostPosted: Aug 18th, 2004 02:05 AM    Post subject: Reply with quote

I think he's posting it for our reference in case we need code to check URLs. Biggrin
_________________
If you happen to see little people sitting on your desk...don't tell anyone or they might think your crazy too.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic