Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Compare Database
Private Sub SelText(ctrlName As Control)
ctrlName.SelStart = 0
ctrlName.SelLength = Len(ctrlName.Text)
End Sub
Private Sub Text0_GotFocus()
If Me.Text0.Text = "" Then
Exit Sub
Else
Call SelText(Text0)
End If
End Sub
Private Sub Text2_GotFocus()
If Me.Text2.Text = "" Then
Exit Sub
Else
Call SelText(Text2)
End If
End Sub
Captain,
The way I read this is that each Textbox still requires the SelText sub in it's GOTFOCUS. Am I reading this right?
Option Compare Database
Private Sub SelText(ctrlName As Control)
If ctrlName.Text = "" Then
Exit Sub
Else
ctrlName.SelStart = 0
ctrlName.SelLength = Len(ctrlName.Text)
End If
End Sub
Private Sub Text0_GotFocus()
Call SelText(Text0)
End Sub
Private Sub Text2_GotFocus()
Call SelText(Text2)
End Sub
Private Sub cmdGenerateEventsCode_Click()
Dim sClip As String
Dim sObj As String
Dim sSub As String
Dim sOrig As String
Dim ctl As Control
Clipboard.Clear
sOrig = "Private Sub XXX_GotFocus()"
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
sObj = ctl.Name
sSub = Replace(sOrig, "XXX", ctl.Name)
sSub = sSub & vbCrLf & " sSelectText " & ctl.Name & vbCrLf & "End Sub" & vbCrLf & vbCrLf
sClip = sClip & sSub
End If
Next
Clipboard.SetText sClip
MsgBox "The code for all the textbox GotFocus events is in the Clipboard"
End Sub
They discuss 'detacting when you're in the IDE' to avoid this potentially aggravating situation. Would you care to comment and give us all some more brain food?If this is true subclassing (which I think it is), there will be (at least) one drawback -
If you stop your program with the End button in the IDE, it will crash.
If you place a break point in your program, it will crash.
And if there is an error and the program stops(in the IDE), it will crash.