How can I trim a string as follows?
Dim MyText AS String
MyText = "X1123-2"
so that MyText can become "X1123"
Dim MyText AS String
MyText = "X1123-2"
so that MyText can become "X1123"
Public Function BeforeDash(StringIn As String) As String Dim DashPos As Integer Const Separator = "-" DashPos = InStr(1, StringIn, Separator) If DashPos > 0 Then BeforeDash = Left$(StringIn, DashPos - 1) Else BeforeDash = StringIn End If End Function
Comment