Access VBA | How to replace parts of a string with another string

后端 未结 4 1887
耶瑟儿~
耶瑟儿~ 2020-12-14 14:11

I am trying to create a piece of code that replaces one word with another. Example: Replace Avenue with Ave and North with N. I am using MS Access, I could use SQL REPLACE F

4条回答
  •  自闭症患者
    2020-12-14 14:59

    Since the string "North" might be the beginning of a street name, e.g. "Northern Boulevard", street directions are always between the street number and the street name, and separated from street number and street name.

    Public Function strReplace(varValue As Variant) as Variant
    
    Select Case varValue
    
        Case "Avenue"
            strReplace = "Ave"
    
        Case " North "
            strReplace = " N "
    
        Case Else
            strReplace = varValue
    
    End Select
    
    End Function
    

提交回复
热议问题