Which command in VBA can count the number of characters in a string variable?

三世轮回 提交于 2019-12-01 04:13:49

Do you mean counting the number of characters in a string? That's very simple

Dim strWord As String
Dim lngNumberOfCharacters as Long

strWord = "habit"
lngNumberOfCharacters = Len(strWord)
Debug.Print lngNumberOfCharacters
Len(word)

Although that's not what your question title asks =)

Len is what you want.

word = "habit"  
length = Len(word)

Use the Len function

length = Len(myString)

Try this:

word = "habit"
findchar = 'b"
replacechar = ""
charactercount = len(word) - len(replace(word,findchar,replacechar))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!