473,395 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Searching text in ASP.net

I use a the function Instr() in VB6 to search for a search-string in String
var. It returns the position of the found search-string.

Is there such a funtion in ASP.net?
Nov 21 '05 #1
2 1294
Hi,

You could try this:

Dim findIt as String = "The String"
Dim startPosition as Integer
Dim position as integer = findIt.IndexOf("String you are looking in",
startPosition)

Hope this helps.

Stuart
MCSD, MCT

More Examples from MSDN:

[Visual Basic]
' Sample for String.IndexOf(Char, Int32)
Imports System

Class Sample
Public Shared Sub Main()

Dim br1 As String =
"0----+----1----+----2----+----3----+----4----+----5----+----6----+-"
Dim br2 As String =
"0123456789012345678901234567890123456789012345678 901234567890123456"
Dim str As String = "Now is the time for all good men to come to the
aid of their party."
Dim start As Integer
Dim at As Integer

Console.WriteLine()
Console.WriteLine("All occurrences of 't' from position 0 to {0}.",
str.Length - 1)
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2,
str)
Console.Write("The letter 't' occurs at position(s): ")

at = 0
start = 0
While start < str.Length AndAlso at > - 1
at = str.IndexOf("t"c, start)
If at = - 1 Then
Exit While
End If
Console.Write("{0} ", at)
start = at + 1
End While
Console.WriteLine()
End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'All occurrences of 't' from position 0 to 66.
'0----+----1----+----2----+----3----+----4----+----5----+----6----+-
'0123456789012345678901234567890123456789012345678 901234567890123456
'Now is the time for all good men to come to the aid of their party.
'
'The letter 't' occurs at position(s): 7 11 33 41 44 55 64
'
'

[C#]
// Sample for String.IndexOf(Char, Int32)
using System;

class Sample {
public static void Main() {

string br1 =
"0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
string br2 =
"0123456789012345678901234567890123456789012345678 901234567890123456";
string str = "Now is the time for all good men to come to the aid of
their party.";
int start;
int at;

Console.WriteLine();
Console.WriteLine("All occurrences of 't' from position 0 to {0}.",
str.Length-1);
Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2,
str);
Console.Write("The letter 't' occurs at position(s): ");

at = 0;
start = 0;
while((start < str.Length) && (at > -1))
{
at = str.IndexOf('t', start);
if (at == -1) break;
Console.Write("{0} ", at);
start = at+1;
}
Console.WriteLine();
}
}
/*
This example produces the following results:

All occurrences of 't' from position 0 to 66.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
01234567890123456789012345678901234567890123456789 01234567890123456
Now is the time for all good men to come to the aid of their party.

The letter 't' occurs at position(s): 7 11 33 41 44 55 64
"jty202" <jt****@gmail.com> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
I use a the function Instr() in VB6 to search for a search-string in String
var. It returns the position of the found search-string.

Is there such a funtion in ASP.net?

Nov 21 '05 #2
jty,

As far as I know is the Instr in VB6 the same as in VBNet
(You can use it as well in C# when you set a reference to the
Microsoft.VisualBasic namespace)

http://msdn.microsoft.com/library/de...vafctinstr.asp

I hope this helps?

Cor
Nov 21 '05 #3

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

Similar topics

2
by: Michi | last post by:
Hello, I am creating a databse with a large number of text (or blob?) entries. I want users to be able to search these fields. An example would be a forum or journal. Indexing every word in...
4
by: Michi | last post by:
I was wondering what the best solution is for making large numbers of TEXT (or BLOB?) fields searchable. For example, if I have a forum, what is the best way to be able to search for specific...
2
by: Roberto Dias | last post by:
Hi all, What to do for searching for more than one string occurrence in the same string (this last are line of a text). I have used getline(), to get the text lines by means of WHILE loop and...
3
by: Paul H | last post by:
I have a text file that contains the following: ******************** __StartCustomerID_41 Name: Fred Smith Address: 57 Pew Road Croydon
8
by: Gordon Knote | last post by:
Hi can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++). The search should be as fast as possible and it would...
3
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
1
Corster
by: Corster | last post by:
I went through a great deal of hassle to figure this out for myself, but now it is complete, I would like to share it with the world! I know afew other people have had trouble with FindFirst and...
4
by: Costa | last post by:
I am looking for a c/c++ text search engine library that supports: - free text searching - not only beginning of words but substrings as well - wildcard searching - I want strings such as...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
1
by: alamodgal | last post by:
hiiiiiii I have a problem in highlighting searching keyword.Actually im using this function for searching Public Function HighLight(ByVal Keyword As String, ByVal ContentFor As String) Dim...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.