Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character
Check if variable contains string before character Check if variable contains string before character
Check if variable contains string before character
Go Back  Xtreme Visual Basic Talk > > > Check if variable contains string before character


Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2010, 01:56 PM
haymaker87 haymaker87 is offline
Newcomer
 
Join Date: Nov 2010
Posts: 2
Default Check if variable contains string before character


Hi,
i have the following code:

Code:
 
  webpage = e.Url.AbsoluteUri.ToString
        If aryTextFile.Contains(webpage) Then
            TextBox1.Text = "your allowed here"
        Else
            TextBox1.Text = "your not allowed there"
        End If

the websites are in a txt file in the format of
http://www.google.com/,http://www.yahoo.com/,

i need to extend the code as at the moment the url has to exatcly match the url in the file so as soon as you leave the homepage and the address grows your not allowed again.


is there away to use substring or some kind of regex to say as long as string begins with the value anything can come after the 3rd /

Thanks for any help
Reply With Quote
  #2  
Old 11-23-2010, 04:50 AM
haymaker87 haymaker87 is offline
Newcomer
 
Join Date: Nov 2010
Posts: 2
Default

i had obvously been staring at the screen tol ong heres the correct way to do it if anyone stumbles on this

I was running contains on the whole array rather than the individual string

Code:
   Dim Test(5) As String
        Dim Test2 As String
        Dim i As Integer = 0

        Test(0) = "something this"
        Test(1) = "this something"
        Test(2) = "something this"
        Test(3) = "this something"
        Test(4) = "blah"
        Test(5) = "something"
        Test2 = "this"

        While i <= 5
            If Test(i).Contains(Test2) Then
                MsgBox("it has this in")
            Else
                MsgBox("it does not have this in")
            End If
            i = i + 1


        End While
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character Check if variable contains string before character
Check if variable contains string before character
Check if variable contains string before character
 
Check if variable contains string before character
Check if variable contains string before character
 
-->