-
I I have a string and I would like to only use a portion of the string, what function should I use?
For example:
strString = "This is fun!"
I want to use "This is" only
How would I cut off everthing after "_f" and only use "This is"
Thanks for any help, VolFans
-
Left$(strString,InstrRev(strString," ")-1)
-------------------------------
Visual Basic Professional 6.0
-
Dim strArray() As String
Dim strTest as String
strTest = "This Is A Test"
'Use the Split Function
strArray = Split(strTest, " ")
MsgBox strArray(1)
MsgBox strArray(2)
HTH
-
<?>
Code:
'slight drawback..it finds the first f
'that could be a problem
Option Explicit
Private Sub Command1_Click()
Dim SearchString, SearchChar, MyPos
SearchString = "This is fun." ' String to search in.
SearchChar = "f"
MyPos = InStr(1, SearchString, SearchChar, 1)
'if found MyPos will be > 0
If MyPos > 0 Then
SearchString = Left(SearchString, MyPos - 1)
SearchString = Trim(SearchString)
MsgBox SearchString
End If
End Sub
[Edited by HeSaidJoe on 10-05-2000 at 01:02 PM]