|
-
Jul 26th, 2003, 06:07 PM
#1
Thread Starter
Sleep mode
again , VB.NET equivalent??[Resolved]
What's the equivalent of InStr that accepts (string, string) and return an integer specifying the start position of the first occurrence of one string within another. I had a look at Compare methods but it didn't help much .
VB Code:
Dim lNullPos As Integer
Dim sBuffer As String
lNullPos = InStr(sBuffer, vbNullChar)
Last edited by Pirate; Jul 26th, 2003 at 07:06 PM.
-
Jul 26th, 2003, 06:12 PM
#2
Hyperactive Member
Do you code in Visual Studio? The intellisense would list all of the available functions in the String class.
Dim strMyString as String = "Whatever"
Dim intIndex as Integer = strMyString.IndexOf("ate")
-
Jul 26th, 2003, 06:40 PM
#3
Thread Starter
Sleep mode
Not sure if that would solve it but I need something like the code I posted . I mean boths string variables will not be fixed , they're always change . So .....
-
Jul 26th, 2003, 06:51 PM
#4
VB Code:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim x As String = "hello : ) How are you"
MessageBox.Show(x.IndexOf("How"))
'Or
MessageBox.Show(InStr(x, "How") - 1)
End Sub
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 26th, 2003, 06:52 PM
#5
Hyperactive Member
Dim mytext As String = "abc"
Dim mypos As integer = InStr(mytext, "c", CompareMethod.Text)
In this case mypos will be set to 3. You can also use a compare method of binary.
was that what you were looking for?
-
Jul 26th, 2003, 06:55 PM
#6
Thread Starter
Sleep mode
I want to replace InStr function which for VB6 Code imported from VisualBasic namespace with pure .NET way . That's what I'm looking for .
-
Jul 26th, 2003, 06:56 PM
#7
Thread Starter
Sleep mode
btw , keep in mind that both strings are changeable . So the code dynamic_sysop and RichardAtherton are not applicable .
Thanks guys .
-
Jul 26th, 2003, 07:03 PM
#8
Thread Starter
Sleep mode
Never mind , figured it out
VB Code:
lNullPos = sBuffer.IndexOf(Nothing) + 1
-
Jul 26th, 2003, 07:05 PM
#9
Thread Starter
Sleep mode
Thanks both of you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|