ASP.net
ASP / ASP.Net / Vignette
ASP / ASP.Net / Oracle
Books RSS Feed for ASPMatrix.com Book Reviews
 
 
Partner Sites
www.learnasp.com
 
ASPFriends.com

www.411asp.net

www.wwwcoder.com
   
 
ASP.net > String Class Examples > IndexOf
 
IndexOf Example 1 - IndexOf(Char)
This will return the first index of the specified char in a string. Returns either the position as a positive Integer, or a  -1 if not found.
 
String to Parse: "My name is Mud! Not to be confused with ..." 
 
Code: IndexOf(Char)
 
 
View the code to do it below.
 
'------------------- begin code ----------------------------

<%@ Page Language="VB" %>
<script runat="server">
const strParse as string = "My name is Mud! Not to be confused with ..."

sub page_load(S as Object, e as EventArgs)
     parseme.text = strParse
 end sub

sub Control_Click(S as Object, E as EventArgs)
   
dim sb as new stringbuilder
    dim ss1example as string

    ss1example = strParse.IndexOf("!")
    sb.append("<b>Results: </b><font color=""#0099FF"">" & ss1example & "</font>")

    results.text=sb.tostring()
end sub
</script>

<html>
...

<form runat="server">
Parse: <I><font color="red">"<asp:literal id="parseme" runat="server" />" </font></I><br />
<asp:Button id="btnSubmit" text="Run Code >>" onclick="Control_Click" runat="server" /><br />
<asp:literal id="results" runat="server" /><br />
</form>

...
</html>

'------------------- end code ----------------------------

 
       
      Please report all site problems to: webmaster@aspmatrix.com