How to: Make A Highlighter
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
1 post
Page 1 of 1
Hello, guys. This is 3aaBrSbeel. I haven't posted for such a long time so I'm posting a new one lmao;
Okay, this tutorial will show you how to make a highlighter.
You'll need.
Re-name the buttons text to "Find"
Place the RichTextBox below TextBox and Button.
If you are done with that, double-click the form then you'll have Form_Load.
Add this on Form_Load.
Thanks, #mshimranpro for his "Last Copied Text" tutorial cooll;
Let's continue, add the codes below under Public Class Form
Copy the codes below and right-click your Form and choose View Source.
Paste the codes between End Sub and End Class.
Okay, this tutorial will show you how to make a highlighter.
You'll need.
- A RichTextBox
A Button
and A TextBox
Re-name the buttons text to "Find"
Place the RichTextBox below TextBox and Button.
If you are done with that, double-click the form then you'll have Form_Load.
Add this on Form_Load.
Code: Select all
Edit the MsgBox to your desire.Try
If My.Computer.Clipboard.ContainsText() Then
Dim ClipText As String
ClipText = My.Computer.Clipboard.GetText
RichTextBox1.Text = (ClipText)
End If
Catch ex As Exception
MsgBox("Looks like you don't have any last copied text.", MsgBoxStyle.Information, "NiCz Productions")
End Try
Thanks, #mshimranpro for his "Last Copied Text" tutorial cooll;
Let's continue, add the codes below under Public Class Form
Code: Select all
Double-click the Button, copy and paste the codes to Button.
Dim start As Integer = 0
Dim indexOfSearchText As Integer = 0
Code: Select all
Double-click TextBox, copy and paste the codes to TextBox.
Dim startindex As Integer = 0
If TextBox1.Text.Length > 0 Then
startindex = FindMyText(TextBox1.Text.Trim(), start, RichTextBox1.Text.Length)
End If
' If string was found in the RichTextBox, highlight it
If startindex >= 0 Then
' Set the highlight color as red
RichTextBox1.SelectionColor = Color.Red
' Find the end index. End Index = number of characters in textbox
Dim endindex As Integer = TextBox1.Text.Length
' Highlight the search string
RichTextBox1.Select(startindex, endindex)
' mark the start position after the position of
' last search string
start = startindex + endindex
End If
'RichTextBox1.SelectionColor = Color.Green
'RichTextBox1.Sele = "World, Hello, I'm NiCz (3aaBrSbeel)"
Code: Select all
Last thing, to make the program functional we need the function.start = 0
indexOfSearchText = 0
Copy the codes below and right-click your Form and choose View Source.
Paste the codes between End Sub and End Class.
Code: Select all
That's all, you can highlight the last thing you copied. Thanks for your time on this tutorial thank you. loove;Public Function FindMyText(ByVal txtToSearch As String, ByVal searchStart As Integer, ByVal searchEnd As Integer) As Integer
' Unselect the previously searched string
If searchStart > 0 AndAlso searchEnd > 0 AndAlso indexOfSearchText >= 0 Then
RichTextBox1.Undo()
End If
' Set the return value to -1 by default.
Dim retVal As Integer = -1
' A valid starting index should be specified.
' if indexOfSearchText = -1, the end of search
If searchStart >= 0 AndAlso indexOfSearchText >= 0 Then
' A valid ending index
If searchEnd > searchStart OrElse searchEnd = -1 Then
' Find the position of search string in RichTextBox
indexOfSearchText = RichTextBox1.Find(txtToSearch, searchStart, searchEnd, RichTextBoxFinds.None)
' Determine whether the text was found in richTextBox1.
If indexOfSearchText <> -1 Then
' Return the index to the specified search text.
retVal = indexOfSearchText
End If
End If
End If
Return retVal
End Function
You do not have the required permissions to view the files attached to this post.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023