如何从段落中获取单词的位置? [英] How to get position of a word from paragraph?

查看:122
本文介绍了如何从段落中获取单词的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,



在我的窗口应用程序中进行验证,如果用户错过标记内容,我需要提示错误。内容显示在文本框中。在下面的代码和& sHint有特定的line.i找到标签丢失的地方。但我想保持光标在起始行的位置?。如何将光标保持在sHint?



另外如何突出显示文本框中的sHint值



Dear Friends,

In my window application for validation purpose i need to prompt the error if the user missed to tag the content. The content showned in the text box.In the below code & sHint having the particular line.i found where the tag missed.But i want to keep position of the cursor in the starting line?.how to keep the cursor in sHint?

In otherway how to highlight the sHint value in textbox

If MsgBox("Pg-Ref (or) cross-ref tagged without ref-group tag" & vbCrLf & vbCrLf & "Hint=>" & sHint & vbCrLf & vbCrLf & "Are you sure to close?", vbYesNo) = vbNo Then
Exit Sub
End If

推荐答案

i不明白这个问题非常好,但你可以使用string.IndexOf()来获取段落中单词的位置!

i did not understand the question very well, but you can use the string.IndexOf() to get the postion of a word in a paragraph!
string msg = "abcdefghijklm...";
int index = msg.IndexOf("fghi"); // the value is 5 in this case
//if the word dont exsist, you will get an exception so better test if the word exsist before getting the index.

if(msg.IndexOf("fghi") != -1)
{
}


这篇关于如何从段落中获取单词的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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