_ Replace text in All text boxes contained in frames, form, and/or pictureboxes
I noticed an article recently posted about this. I am posting this because it is a much more efficient way to do it. Simple code so I am not expecting votes, but if you like it please feel free :)
Original Author: KRYO_11
Inputs
'Example usage:
'TextBoxMod Me, 0, "Kryo"
'Would make ALL textboxe' text say "Kryo"
API Declarations
'Enum declared to make using following sub easier
Public Enum What2Clear
[Clear All Textbox's] = 0
[Clear Textbox's Contained In Frames] = 1
[Clear Textbox's Contained In Picturebox's] = 2
[Clear Textbox's Contained In Form] = 3
End Enum
Code
Public Sub TextBoxMod(WhichForm As Form, CommandLine As What2Clear, Optional ReplaceWith As String = Empty)
For Each Control In WhichForm 'Search's through given form
If CommandLine = [Clear All Textbox's] Then
If TypeOf Control Is TextBox Then Control.Text = ReplaceWith
'Look for ALL textboxes
ElseIf CommandLine = [Clear Textbox's Contained In Form] Then
'Look for textboxes in Form ONLY
If TypeOf Control Is TextBox And TypeOf Control.Container Is Form Then Control.Text = ReplaceWith
ElseIf CommandLine = [Clear Textbox's Contained In Frames] Then
'Look for textboxes in Frmaes ONLY
If TypeOf Control Is TextBox And TypeOf Control.Container Is Frame Then Control.Text = ReplaceWith
ElseIf CommandLine = [Clear Textbox's Contained In Picturebox's] Then
'Look for textboxes in Pictureboxes ONLY
If TypeOf Control Is TextBox And TypeOf Control.Container Is PictureBox Then Control.Text = ReplaceWith
End If
Next
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.