R
RB
For controls on a form, we used to use the <Focus> event to open the SIP and
and input box for a user to enter/revise text. Now this gets stuck in a
loop since the input box puts focus back on the control it was called from.
Private Function EditCtlDialog(ByVal strCtlName As String, ByVal strCurVal
As String, ByVal intChar As Int16, ByVal strType As String) As String
EditCtlDialog = ""
If blnOpening Then Exit Function
Dim strNewVal As String = "", strMsg As String
If intChar <> 0 Then
strMsg = "Edit text in " + strCtlName + "(" + intChar.ToString + "
characters max)"
Else
strMsg = "Edit " + strCtlName + "(" + strType + ")"
End If
strNewVal = InputBox(strMsg, strCtlName, strCurVal, 20, 20)
Select Case strType
Case "String"
strNewVal = Mid(strNewVal, 1, intChar)
Case "Date"
If Not IsDate(strNewVal) Then
MsgBox("Could not recognize date format", MsgBoxStyle.Exclamation, "Date?")
strNewVal = strCurVal
End If
Case "Number"
If Not IsNumeric(strNewVal) Then
MsgBox("Could not recognize number format " + strNewVal,
MsgBoxStyle.Exclamation, "Number?")
strNewVal = strCurVal
End If
End Select
EditCtlDialog = strNewVal
End Function
----------------------------------
Private Sub txtShipName_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtShipName.GotFocus
InputPanel1.Enabled = True
strNewVal = EditCtlDialog("Ship Name", txtShipName.Text, 40, "String")
InputPanel1.Enabled = False
If strNewVal <> "" Then txtShipName.Text = Trim(strNewVal)
strLastFocus = "txtShipName"
End Sub
------------------------------------------------------
What event can be used for this instead of "Focus"?
Thanks,
RB
and input box for a user to enter/revise text. Now this gets stuck in a
loop since the input box puts focus back on the control it was called from.
Private Function EditCtlDialog(ByVal strCtlName As String, ByVal strCurVal
As String, ByVal intChar As Int16, ByVal strType As String) As String
EditCtlDialog = ""
If blnOpening Then Exit Function
Dim strNewVal As String = "", strMsg As String
If intChar <> 0 Then
strMsg = "Edit text in " + strCtlName + "(" + intChar.ToString + "
characters max)"
Else
strMsg = "Edit " + strCtlName + "(" + strType + ")"
End If
strNewVal = InputBox(strMsg, strCtlName, strCurVal, 20, 20)
Select Case strType
Case "String"
strNewVal = Mid(strNewVal, 1, intChar)
Case "Date"
If Not IsDate(strNewVal) Then
MsgBox("Could not recognize date format", MsgBoxStyle.Exclamation, "Date?")
strNewVal = strCurVal
End If
Case "Number"
If Not IsNumeric(strNewVal) Then
MsgBox("Could not recognize number format " + strNewVal,
MsgBoxStyle.Exclamation, "Number?")
strNewVal = strCurVal
End If
End Select
EditCtlDialog = strNewVal
End Function
----------------------------------
Private Sub txtShipName_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtShipName.GotFocus
InputPanel1.Enabled = True
strNewVal = EditCtlDialog("Ship Name", txtShipName.Text, 40, "String")
InputPanel1.Enabled = False
If strNewVal <> "" Then txtShipName.Text = Trim(strNewVal)
strLastFocus = "txtShipName"
End Sub
------------------------------------------------------
What event can be used for this instead of "Focus"?
Thanks,
RB