Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Using String Function 1

Status
Not open for further replies.

jallen919

Technical User
Mar 30, 2001
30
US
I got some help from another tek-tip user on using the string function. I have a column in my DB that sometimes has two strings in a record. If the record has two strings in the specific column, I need to delete the first string and leave the second. If there is only one string, that string neees to remain. The code I'm using is below. If there are two strings in the column a zero is left in place of the two string... I'm not good with VBA coe so any help is appreciated.

Public Function basScndStr(StrIn As String) As String

Dim MyVar As Variant

MyVar = Split(StrIn)
If (UBound(MyVar) = 0) Then
basScndStr = UBound(MyVar)
Else
MyVar(0) = ""
basScndStr = Trim(Join(MyVar))
End If

End Function
 
as ACTUALLY posted!

Code:
Public Function basScndStr(StrIn As String) As String

    'Function to return the Second Str - If there are MORE than one
    'Actually we will delete the first Str it there is more than one

    Dim MyVar As Variant

    MyVar = Split(StrIn)
    If (UBound(MyVar) = 0) Then
        basScndStr = MyVar(UBound(MyVar))
    Else
        MyVar(0) = ""
        basScndStr = Trim(Join(MyVar))
    End If
        
End Function
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
thanks so much -- I thought I just copied and pasted last time but apparantly I didn't. You saved me days worth of manual work -- thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top