home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,600 of 10,840   
   Per Juul Larsen to All   
   Re: extracting a string from a string   
   12 Jul 08 09:07:33   
   
   From: juul@larsen.dk   
      
   Jason Keats skrev:   
   > Per Juul Larsen wrote:   
   >> hi.   
   >>   
   >> I do want to extract this string "abcdefg" from string   
   >> "C:\dir1\dir2\abcdefg-12345gsd"   
   >>   
   >>     Note : the length of the text string "abcdefg" may vary, but the   
   >> last character is always "-".   
   >> I need only the string "abcdefg" not "-12345gsd"   
   >>   
   >> thanks pjl Denmark   
   >   
   > Assuming you're using VB6...   
   >   
   > Dim s As String   
   > Dim n As Integer   
   >   
   > s = "C:\dir1\dir2\abcdefg-12345gsd"   
   > Debug.Print s   
   >   
   > n = InStrRev(s, "\")   
   > If n > 0 Then   
   >     s = Mid$(s, n + 1)   
   >     Debug.Print s   
   > End If   
   >   
   > n = InStr(s, "-")   
   > If n > 0 Then   
   >     s = Left$(s, n - 1)   
   > End If   
   > Debug.Print s   
   >   
   > Easy, wasn't it?   
   That Easy.. thanks   
   regards pjl   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca