- This topic helps to search character from textbox in vb programming.
- Helps to find a character included in the textbox or richtextbox using vb programming.
- Tools needed for search character from textbox: TextBox1 (TextBox1), TextBox2 (TextBox2), Button1 (Button1).
- Here we search a character “a” from the TextBox using vb programming with the help of string Builder.
TextBox Class – Search character from textbox in vb
- It represents a control that can be used to display or edit unformatted text.
- Syntax for Search character from textbox in vb
|
1 2 3 4 5 6 |
'Declaration <LocalizabilityAttribute(LocalizationCategory.Text)> _ <ContentPropertyAttribute("Text")> _ Public Class TextBox _ Inherits TextBoxBase _ Implements IAddChild |
System.Text Namespace – Search character from textbox in vb
- The System.Text namespace contains classes that represent ASCII and Unicode character encodings.
- Abstract base class for converting blocks of characters to and from blocks of bytes.
- A helper class that manipulates and formats String objects without creating intermediate instances of String.
System.Text.StringBuilder – Search character from textbox in vb
- StringBuilder represents a mutable string of characters. This class cannot be inherited.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
- Syntax for StringBuilder
|
1 2 3 4 5 |
'Declaration <SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class StringBuilder _ Implements ISerializable |
StringBuilder.Append Method (Char) – Search character from textbox in vb
- This method appends the string representation of a specified Unicode character to this instance.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
- Syntax for Append Method
|
1 2 3 4 |
'Declaration Public Function Append ( _ value As Char _ ) As StringBuilder |
Search character from textbox in vb – Complete Code
|
1 2 3 4 5 6 7 8 9 10 11 |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Click.Click Dim str As String str = TextBox1.Text Dim sb1 As New System.Text.StringBuilder For Each ch As Char In str If ch = "a" Then sb1.Append(ch) End If Next TextBox2.Text = sb1.ToString() End Sub |
Search character from textbox in vb – Please provide feedback about this topic.







