您如何获得字母的数字位置? [英] how do you get a letter's number position?

查看:165
本文介绍了您如何获得字母的数字位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带句子的字符串.该字符串显示在一个富文本框中.用户在文本框中键入一个字母,然后程序尝试在字符串中找到该字母.我想让用户按下按钮时出现一个消息框,并显示字母以及其在字符串中的数字位置.

例如,如果我的句子中有10个字母,而用户键入的字母是5,该如何在消息框中显示该字母的数字?

谢谢.

Hi, I have a string with a sentence. The string is displayed in a richtextbox. The user types a letter in a textbox and the program attempts to find that letter in the string. I want to make it that when the user presses a button a messagebox appears and displays the letter along with its numeric position in the string.

For example, if my sentence has 10 letters and the letter that the user types is number 5 how do I display that letter''s number in the messagebox?

Thanks.

推荐答案

为文本框的KeyPress事件提供处理程序.然后查看"e.KeyChar".
Make a handler to the KeyPress event of the textbox. Then check out ''e.KeyChar''.


这篇关于您如何获得字母的数字位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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