如何计算特殊字符? [英] How to count special characters?

查看:100
本文介绍了如何计算特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好专家,


我有一张表格。


在这个表格中有一个名为txtName的文本框。和1个名为btnCountChar的按钮

我想计算在文本框中输入的特殊字符。我怎样才能做到这一点?请帮我。这很紧急。


提前谢谢。

Hello experts,

I have 1 form.

In this form there is one textbox named "txtName" and 1 button named"btnCountChar"

I want to count the special characters entered in the textbox. How can I do this? Please help me. It''s urgent.

Thank you in advance.

推荐答案

在按钮单击事件处理程序中实现检索的代码来自 txtName 的文本。


一旦你有了字符串,你应该遍历其中的字符并增加一个计数器每次你找到一个特殊字符。


或者你可以尝试使用 String.IndexOfAny方法 ...


或者你可以考虑使用正则表达式尝试实现同样的事情。


-Frinny
In the button click event handler implement code that retrieves text from the from the txtName.

Once you have the string, you should loop through the characters within it and increment a counter every time you find a "special character".

Or you could try using the String.IndexOfAny Method...

Or you could consider using regular expressions to try an achieve the same thing.

-Frinny


哦!弗林尼非常感谢你的回复。我会尝试一下。
Oh! Frinny thank you so much for your reply. I would try it.


你好Frinny,


我已经访问并阅读了你的链接,但我无法理解如何使用代码。


我明白,你在

中说了什么一旦你有了字符串,你应该循环遍历其中的字符并每增加一个计数器你找到特殊字符的时间。但我想知道如何检查给定字符是否是特殊字符


For例如,

如果我输入嗨!你好,你好吗?< 进入 txtName 然后MsgBox应该在 btnCountChar上显示答案 7 点击活动。


你能解释一下如何计算输入字符串中可用的特殊字符吗?


谢谢你提前回复并感谢你的帮助......
Hello Frinny,

I have visited and read your link, but I can''t understand how to use the code.

I understand, what you say in
"Once you have the string, you should loop through the characters within it and increment a counter every time you find a "special character".", but I want to know how to check if the given character is special character or not

For example,
If I enter "Hi! Hello, How are you?" into the txtName then MsgBox should display the answer 7 on btnCountChar''s click event.

Can you explain me how to count special characters available in the entered string?

Thank you in advance for your reply and also thank you for your help...


这篇关于如何计算特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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