访问 VBA |如何用另一个字符串替换部分字符串 [英] Access VBA | How to replace parts of a string with another string

查看:68
本文介绍了访问 VBA |如何用另一个字符串替换部分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一段代码,用另一个词替换一个词.示例:将 Avenue 替换为 Ave,将 North 替换为 N.我正在使用 MS Access,我可以使用 SQL REPLACE 函数,但我想在 VBA 中使用 Access 模块执行此操作,以便我可以将该函数附加到其他列.

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 Function but I want to do this in VBA using Access module so that I can attached the function to other column.

我不知道从哪里开始,所以任何输入都将不胜感激.

I am not sure where to start with this, so any input will be greatly appreciated.

伙计

推荐答案

使用 Access 的 VBA 功能 Replace(text, find, replacement):

Use Access's VBA function Replace(text, find, replacement):

Dim result As String

result = Replace("Some sentence containing Avenue in it.", "Avenue", "Ave")

这篇关于访问 VBA |如何用另一个字符串替换部分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆