473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable Contains question

Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and if it
does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.
Jul 19 '05 #1
15 7599
<%

If CheckIt(stringt ocheck) = True Then
Response.Redire ct "itsthere.a sp"
Else
Response.Write "it's not there"
End If

Function CheckIt(strStri ng)
If Instr(String, "director") Then
CheckIt = True
Else
CheckIt = False
End Function
End Function

%>

Or simply;

<%
If Instr(StringToC heck, "director") Then
Response.Write "it's there"
Else
Response.Write "it's not there"
End If
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Miguel Orrego <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and if it does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.

Jul 19 '05 #2
Hi Steve,

Thanks for your reply, however that only seems to work if the string
contains only the word director, if for example it contains "senior
director" it doesn't work.

How can I amend that so that if it contains the word director, irrespective
of what else is there, it returns true?

Thanks again.
"Steven Burn" <nobody@PVT_i t-mate.co.uk> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
<%

If CheckIt(stringt ocheck) = True Then
Response.Redire ct "itsthere.a sp"
Else
Response.Write "it's not there"
End If

Function CheckIt(strStri ng)
If Instr(String, "director") Then
CheckIt = True
Else
CheckIt = False
End Function
End Function

%>

Or simply;

<%
If Instr(StringToC heck, "director") Then
Response.Write "it's there"
Else
Response.Write "it's not there"
End If
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Miguel Orrego <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and
if it
does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.


Jul 19 '05 #3
It shouldn't be doing that..... but, you can always modify;

If Instr(String, "director") Then

to

If Instr(String, " director") Then

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Miguel Orrego <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** **************@ news.dial.pipex .com...
Hi Steve,

Thanks for your reply, however that only seems to work if the string
contains only the word director, if for example it contains "senior
director" it doesn't work.

How can I amend that so that if it contains the word director, irrespective of what else is there, it returns true?

Thanks again.
"Steven Burn" <nobody@PVT_i t-mate.co.uk> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
<%

If CheckIt(stringt ocheck) = True Then
Response.Redire ct "itsthere.a sp"
Else
Response.Write "it's not there"
End If

Function CheckIt(strStri ng)
If Instr(String, "director") Then
CheckIt = True
Else
CheckIt = False
End Function
End Function

%>

Or simply;

<%
If Instr(StringToC heck, "director") Then
Response.Write "it's there"
Else
Response.Write "it's not there"
End If
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Miguel Orrego <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and

if
it
does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.



Jul 19 '05 #4
"Miguel Orrego" wrote:
: I have a variable in an app called GenericTitle which contains text, a
: persons job title funnily enough.
:
: I want to check whether this variable contains the word "director" and if
it
: does, then redirect to another page for example.
:
: Can somebody post some code that would let me check this?

with regular expressions

<%@ Language=VBScri pt %>
<%
Option Explicit
Response.Buffer = True

sub getTitle(strTit le, go, goelse)
Dim re, str, em
str = "director"
Set re = new RegExp
With re
.Pattern = "(\w)+"
.IgnoreCase = True
.Global = false
End With
Set em = re.Execute(strT itle)
if lcase(em(0)) = "director" then
Response.Redire ct(go) ' director
else
Response.Redire ct(goelse) ' not director
end if
set re = nothing
end sub

dim GenericTitle
GenericTitle = Request.QuerySt ring("gt")
getTitle "" & GenericTitle & "", "http://wallstreet.com/",
"http://disney.com"
%>

You can test it here:
http://kiddanger.com/lab/regexp1.asp?gt=director
http://kiddanger.com/lab/regexp1.asp?gt=janitor

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #5
Nice job on the coding...but since some folks do their news'ing at work I
personally wouldn't have redirected to a site (wallstreet.com ) with gambling
on it. I worked at an organization a few years back that tracked every move
I made on the internet, and that site would have earned me a reprimand.

Just food for thought.

--
William Morris
Product Development, Seritas LLC
Kansas City, Missouri

"Roland Hall" <nobody@nowhere > wrote in message
news:OP******** ******@TK2MSFTN GP12.phx.gbl...
"Miguel Orrego" wrote:
: I have a variable in an app called GenericTitle which contains text, a
: persons job title funnily enough.
:
: I want to check whether this variable contains the word "director" and if it
: does, then redirect to another page for example.
:
: Can somebody post some code that would let me check this?

with regular expressions

<%@ Language=VBScri pt %>
<%
Option Explicit
Response.Buffer = True

sub getTitle(strTit le, go, goelse)
Dim re, str, em
str = "director"
Set re = new RegExp
With re
.Pattern = "(\w)+"
.IgnoreCase = True
.Global = false
End With
Set em = re.Execute(strT itle)
if lcase(em(0)) = "director" then
Response.Redire ct(go) ' director
else
Response.Redire ct(goelse) ' not director
end if
set re = nothing
end sub

dim GenericTitle
GenericTitle = Request.QuerySt ring("gt")
getTitle "" & GenericTitle & "", "http://wallstreet.com/",
"http://disney.com"
%>

You can test it here:
http://kiddanger.com/lab/regexp1.asp?gt=director
http://kiddanger.com/lab/regexp1.asp?gt=janitor

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #6
That's not true. What you are probably running into is a case sensitivity
problem. Change Steven's code to:

Function CheckIt(pString )
If Instr(lcase(pSt ring), "director") Then
CheckIt = True
Else
CheckIt = False
End if
End Function

HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is
my spam trap, so I don't check it very often. You will get a quicker
response by posting to the newsgroup.

"Miguel Orrego" <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** **************@ news.dial.pipex .com...
Hi Steve,

Thanks for your reply, however that only seems to work if the string
contains only the word director, if for example it contains "senior
director" it doesn't work.

How can I amend that so that if it contains the word director, irrespective of what else is there, it returns true?

Thanks again.
"Steven Burn" <nobody@PVT_i t-mate.co.uk> wrote in message
news:e9******** ******@TK2MSFTN GP10.phx.gbl...
<%

If CheckIt(stringt ocheck) = True Then
Response.Redire ct "itsthere.a sp"
Else
Response.Write "it's not there"
End If

Function CheckIt(strStri ng)
If Instr(String, "director") Then
CheckIt = True
Else
CheckIt = False
End Function
End Function

%>

Or simply;

<%
If Instr(StringToC heck, "director") Then
Response.Write "it's there"
Else
Response.Write "it's not there"
End If
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Miguel Orrego <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and

if
it
does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.



Jul 19 '05 #7
Bob Barrows [MVP] wrote on 12 feb 2004 in
microsoft.publi c.inetserver.as p.general:
Function CheckIt(pString )
If Instr(lcase(pSt ring), "director") Then
CheckIt = True
Else
CheckIt = False
End if
End Function


Function CheckIt(pString )
CheckIt = Instr(lcase(pSt ring), "director") >0
End Function
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #8
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Change Steven's code to:

If Instr(lcase(pSt ring), "director") Then


Or, perhaps even better...

If Instr( 1, pString, "director", 1 ) > 0 Then

HTH,
Phill W.
Jul 19 '05 #9
Thanks for the help guys, I've got it working fine now, except for some
people in my org don't have Directors, so I now need to change it to check
for director or vp or senior manager.

What would the syntax be in the function for it to check for more than one
word? :

Function CheckIt(pString )
If Instr(lcase(pSt ring), "director") Then
CheckIt = True
Else
CheckIt = False
End if
End Function

Thanks again all.
"Miguel Orrego" <mi****@stresse dmonkey.net-nospam> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi,

I have a variable in an app called GenericTitle which contains text, a
persons job title funnily enough.

I want to check whether this variable contains the word "director" and if it does, then redirect to another page for example.

Can somebody post some code that would let me check this?

Your help is much appreciated.

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1472
by: Mal Ice | last post by:
I am creating an initial index.htm page on which I show some disclaimers and introduction information. In the head section I have Javascript which determines the screen resolution of the client. I assign values to two variables to assign the width and height. (my_width and my_height). I have a Form button which is clicked on agreeing to the disclaimers. On clicking the form button I want to direct the user (open a new window) to a...
6
1354
by: arcticool | last post by:
Fields vs. Local Variables- as I understand a Field (declared inside a class) can share data across methods in the class, and to other classis (if declared public) where local variables (declared inside a method) are scoped only within the method. So my question is: what would be the point of declaring a local variable *public* ? Thanks, AC
2
1078
by: Bit byte | last post by:
I have a C function that takes variable args, i.e. is of the form : foo( const char*, const int, ... ) ; I want to expose this function so that I can call it from VB(6). My questions are: 1). Is it possible to export a function with variable args in a DLL? 2). How would such a functon be called from VB ? (Ok, this may not be the correct group for a question on VB but, it is related to what I'm
0
1354
by: ajay.kalyan | last post by:
I am trying to add an object to an arraylist, but first I need to see if the an object with a specified instance value already exists in the arraylist. The Contains(obj) function checks the entire object but I only need to check 1 instance variable in the object and return true or false based on that. My java experience tells me that it might have something to do with the CompareTo() method, but I dont even know if the CompareTo method...
1
1617
by: Mark Huebner | last post by:
If I have a class C that contains a private variable (property) V and private function T and T is executed within C as a separate thread, does thread T have access to private variable (property) V in the instance of class C? It appears to but another person has suggested that this is dangerous and that global variables should be defined in a separate class with the static type modifer.
2
1266
by: mattdaddym | last post by:
Hi, I have a variable question in regards to my asp .net page. I need to declare a variable whose value is readable/writable to all of the subroutines of a specific page. So far I have one of two problems. The first is if I declare my variable right after the class definition, then I can use it anywhere, but the value does not persist from one subroutine to the next.
0
355
by: mosesdinakaran | last post by:
Hi, Is there a way to check weather a variable contains serialized data or not, as we hve some functions like ( is_ double,is_ float) to check the integer and float value. Moses
10
1408
by: nas | last post by:
Hi Is there any way that i can find wether float variable contains fraction?? for eg:- if( isWholeNumber(b)) { //do here }
1
2217
by: Stu Richmond | last post by:
HI can someone please tell me how to check the contents on a variable (which is loading external data) to see if it contains anything. i.e variable "title1" if (title1 =="") {_root.dataholder.button_1._visible = false } this is how I thought it would work, what am I doing wrong
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.