Valhalla Legends Forums Archive | .NET Platform | [C#] Problem...

AuthorMessageTime
Smarter
[code]
Public Function GetString(S As String) As String: GetString = Mid(S, InStr(1, S, Chr(34)) + 1, Len(S) - (InStr(1, S, Chr(34)) + 1)): End Function
[/code]

This code takes the string contained inside quotes("), and then returns it without them, this is used for things like:
|INFO "Blah has banned blah2 (blah)"

Where, if you had split the string by space, it wouldn't give you the quoted text, however I'm not sure how to reproduce this function in C#, I thought of doing a like replace, but then I'd have to use a switch, and parse it for the first two splits, and ugh, i'm just confused.
March 24, 2007, 8:27 PM
dRAgoN
[code]    Public Function GetString(ByVal S As String) As String
        Return S.Substring(S.IndexOf(""""), S.IndexOf("""", S.IndexOf("""") + 1))
    End Function
[/code]

I'm a bit tired atm but this should help you figure out substring abit.
March 25, 2007, 12:48 PM

Search