Results 1 to 4 of 4

Thread: Strings

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    Hello,

    strstriing$ = "\gamez\tony hawk\"
    i want to use instr to find the "\"

    then, for each \ found, use a for/next to get the text inbetween


    so my final result will be
    "gamez"
    "tony hawk"


    My problem is i dont know how to count the "/s"?

    any advice


  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Option Explicit
    
    Private Function Tagless(ByVal Text As String) As String
        
        Dim i As Integer
        Dim x As Integer, y As String
        
          For i = 1 To Len(Text)
             If Mid(Text, i, 1) = "\" Then
                 x = x + 1
             If x = 2 Then
                y = y & vbCrLf
                 x = 1
           End If
             Else
                y = y & Mid(Text, i, 1)
           End If
           
           
       Next
       
        Tagless = y
    End Function
    
    Private Sub Form_Load()
        Dim strString As String
        strString = "\tony\get it\why\not ever if you\dare"
        MsgBox Tagless(strString)
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    Thanks HeSaidJoe

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    u can use the split function instead:

    try this:

    Code:
    Private Sub Command1_Click()
        str1 = "\tony\get it\why\not ever if you\dare"
        str2 = Split(str1, "\")
        For i = 0 To UBound(str2)
            Debug.Print str2(i)
        Next
    End Sub

    [Edited by rammy on 11-09-2000 at 11:13 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width