•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 427,221 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,263 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 1593 | Replies: 13
![]() |
•
•
Join Date: Sep 2007
Posts: 35
Reputation:
Rep Power: 2
Solved Threads: 1
Hi, I'm trying to work out a way i can create my own "find..." or "find next" dialog for a textbox, because i don't think Vb.net has one that you can use, and its vital that i manage to get this otherwise the program wont be much use when editing large documents and you don't want to spend half an hour finding a sentence or a word. Does anybody know of a way i can create my own using strings or maybe something else, i did think about using the split() method and i wouldn't know where to go after that, thanks.
•
•
Join Date: Dec 2002
Location: West Virginia
Posts: 388
Reputation:
Rep Power: 6
Solved Threads: 40
If you are using richtextbox then it has its own find method. Just keep track where you started so you know when you went through the whole document. Keep track of where you currentlly are to start your next find.
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
•
•
Join Date: Dec 2002
Location: West Virginia
Posts: 388
Reputation:
Rep Power: 6
Solved Threads: 40
Add a form to your project and call it frmFind or something like that (see attached image).
My richtextbox is called Editor.
Add this code.
and call it like this
My richtextbox is called Editor.
Add this code.
Public Class frmFind
Private PlaceHolder As Integer
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim x As Integer
Dim opt As RichTextBoxFinds = 0
If ckCaseSensitive.Checked Then opt = opt Or RichTextBoxFinds.MatchCase
If ckWholeWord.Checked Then opt = opt Or RichTextBoxFinds.WholeWord
x = Form1.Editor.Find(txtFind.Text, PlaceHolder, opt)
If x < 0 Then
If MessageBox.Show("There is no more occurances of " & txtFind.Text & vbCrLf & "Start at begining?", "Can't Find", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
PlaceHolder = 0
btnFind.PerformClick()
End If
End If
End Sub
Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplace.Click
Form1.Editor.SelectedText = txtReplace.Text
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub btnFindNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindNext.Click
PlaceHolder = Form1.Editor.SelectionStart + 1
btnFind.PerformClick()
End Sub
Private Sub frmFind_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PlaceHolder = Form1.Editor.SelectionStart
End Sub
Private Sub btnReplaceAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplaceAll.Click
Dim x As Integer
Dim opt As RichTextBoxFinds = 0
If ckCaseSensitive.Checked Then opt = opt Or RichTextBoxFinds.MatchCase
If ckWholeWord.Checked Then opt = opt Or RichTextBoxFinds.WholeWord
PlaceHolder = 0
Do
x = Form1.Editor.Find(txtFind.Text, PlaceHolder, opt)
If x < 0 Then
Exit Do
Else
Form1.Editor.SelectedText = txtReplace.Text
End If
PlaceHolder = Form1.Editor.SelectionStart + 1
Loop
End Sub
End Class frmFind.txtFind.Text = Editor.SelectedText
frmFind.ShowDialog() Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Exe
- Next Thread: Need help with GoTo statements



Linear Mode