Advertisement
4_2005-2006 Miscellaneous #167517

_ 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 :)

AI

AI-sammanfattning: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Källkod
original-source
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
Originalkommentarer (3)
Återställd från Wayback Machine