Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Checking the first 3 characters

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,1229
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Checking the first 3 characters
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Checking the first 3 characters - 8/8/2004 11:17:46 PM   
  nidhim

 

Posts: 1
Score: 0
Joined: 8/8/2004
From:
Status: offline
I'm calling a value from database (numeric column)

Now I want to check the first 3 numbers in that value. And if for eg. first three numbers are 123, I want to do something otherwise not.
So whats the syntax for cheking the first 3 numbers?
 
 
Post #: 1
 
 Re: Checking the first 3 characters - 8/11/2004 3:04:51 AM   
  sachindhillan

 

Posts: 1
Score: 0
Joined: 8/11/2004
From: India
Status: offline
hello nidhim

u can use mid(string, starting position, length) funcation.
Sachin

(in reply to nidhim)
 
 
Post #: 2
 
 Re: Checking the first 3 characters - 8/12/2004 6:41:34 AM   
  cperrywebrat

 

Posts: 4
Score: 0
Joined: 8/12/2004
From: USA
Status: offline
Just why are you using MID, below is some sample code using the LEFT function which makes more sense.
**************

<HTML><HEAD></HEAD>
<BODY>

<% IF Request.Form("inputNumber")<>"" THEN %>
The number you entered is: <%=Request.Form("inputNumber")%><BR>
The first three numbers are: <%=Left(Request.Form("inputNumber"),3)%><BR>
<p><A HREF="test.asp">Input another number</A></p>
<% ELSE %>
<FORM method="post" action="test.asp">
Input a number: <input type="text" name="inputNumber"><br><BR>
<input type="submit" value="submit">
</form>
<% END IF %>

</BODY></HTML>

(in reply to nidhim)
 
 
Post #: 3
 
 Re: Checking the first 3 characters - 8/12/2004 6:46:10 AM   
  cperrywebrat

 

Posts: 4
Score: 0
Joined: 8/12/2004
From: USA
Status: offline
Oh, almost forgot the decision - to do something if the first three numbers are 123, try the code below - it should be fairly simple to modify the code for your needs :-)

<HTML><HEAD></HEAD>
<BODY>

<% IF Request.Form("inputNumber")<>"" THEN %>
The number you entered is: <%=Request.Form("inputNumber")%><BR>
The first three numbers are: <%=Left(Request.Form("inputNumber"),3)%><BR>
<p><A HREF="test.asp">Input another number</A></p>

<% If Left(Request.Form("inputNumber"),3)="123" THEN
Response.Write "<h1>The first 3 numbers were 123!</h1>"
ELSE
Response.Write "<h1>The first 3 numbers were N-O-T 123!</h1>"
END IF
%>

<% ELSE %>

<FORM method="post" action="test.asp">
Input a number: <input type="text" name="inputNumber"><br><BR>
<input type="submit" value="submit">
</form>

<% END IF %>

</BODY></HTML>

(in reply to nidhim)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Checking the first 3 characters Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts