VB6使用RichTextBox。 [英] VB6 working with RichTextBox.
问题描述
我有一个程序打开加密的INI文件(在我的其他程序中用作设置)。
在我的Decrypt Exe中(读取INI文件,解密它并能够编辑文件和另存为加密文本)。其他功能是查找
。
完成单击按钮时,我的问题有时是所选文本查找文本
被 frmFind
隐藏。我想在发生这种情况时设置位置(顶部,左侧)。许多已知应用程序都有此功能。
请帮助...谢谢
这是我的代码找到文字,我不知道是否有更好的解决方案
' 按钮中的代码查找下一步也在frmFind
Dim startText 正如 字符串
Dim endText 正如 字符串
Dim findInt 正如 整数
Dim searchText 正如 字符串
searchText = LCase(txtFind.Text)
如果 Option1.Value 然后
s tartText = LCase(左(frmDecrypt.RichTextBox1.Text,frmDecrypt.RichTextBox1.SelStart))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text,Len(startText)))
findInt = InStr(startText ,searchText)
如果 findInt> 0 然后
frmDecrypt.RichTextBox1.SelStart = findInt - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
其他
frmFind.Visible = False
MsgBox 指定的区域已到达。 ,vbCritical
frmFind.Visible = True
结束 < span class =code-keyword>如果
其他
startText = LCase(左(frmDecrypt.RichTextBox1.Text,frmDecrypt) .RichTextBox1.SelStart + frmDecrypt.RichTextBox1.SelLength))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text,Len(startText)+ 1 ))
findInt = InStr(endText,searchText)
如果 findInt> 0 然后
frmDecrypt.RichTextBox1.SelStart = findInt + Len(startText) - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
否则
frmFind .Visible = False
MsgBox 指定的区域已到达。,vbCritical
frmFind.Visible = True
End 如果
结束 如果
frmDecrypt.SetFocus
屏幕左上角
frmFind.Left = 0
frmFind.Top = 0
' 或当前的左上角表格
frmFind.Left = ME .Left
frmFind.Top = ME .Top
I have a program that open encrypted INI files (used in my other program as a settings).
In my Decrypt Exe (reading the INI file, decrypt it and able to edit the file and save as encrypted text). Other functionalities is Find
.
My problem is sometimes the selected text when finish clicking the button Find Text
is hidden by the frmFind
. I want to set the position(top, left) when that happens. Many known application has this function.
Please Help... Thanks
This is my code in finding text, I don't know if there's a better solution on this
'CODE IN BUTTON "FIND NEXT" ALSO IN frmFind
Dim startText As String
Dim endText As String
Dim findInt As Integer
Dim searchText As String
searchText = LCase(txtFind.Text)
If Option1.Value Then
startText = LCase(Left(frmDecrypt.RichTextBox1.Text, frmDecrypt.RichTextBox1.SelStart))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text, Len(startText)))
findInt = InStr(startText, searchText)
If findInt > 0 Then
frmDecrypt.RichTextBox1.SelStart = findInt - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
Else
frmFind.Visible = False
MsgBox "The specified region has been reach.", vbCritical
frmFind.Visible = True
End If
Else
startText = LCase(Left(frmDecrypt.RichTextBox1.Text, frmDecrypt.RichTextBox1.SelStart + frmDecrypt.RichTextBox1.SelLength))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text, Len(startText) + 1))
findInt = InStr(endText, searchText)
If findInt > 0 Then
frmDecrypt.RichTextBox1.SelStart = findInt + Len(startText) - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
Else
frmFind.Visible = False
MsgBox "The specified region has been reach.", vbCritical
frmFind.Visible = True
End If
End If
frmDecrypt.SetFocus
' top left of screen frmFind.Left = 0 frmFind.Top = 0 ' or top left of current form frmFind.Left = ME.Left frmFind.Top = ME.Top
这篇关于VB6使用RichTextBox。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!