Duke49
Messages postés552Date d'inscriptionjeudi 12 octobre 2006StatutNon membreDernière intervention24 janvier 2023
-
15 janv. 2011 à 18:50
Duke49
Messages postés552Date d'inscriptionjeudi 12 octobre 2006StatutNon membreDernière intervention24 janvier 2023
-
15 janv. 2011 à 21:24
Je débute dans l'Overload, le WithEvents, le Handler.
La fenêtre:
Le problème: La fonction Show ne veut pas attendre l'évènement FormClosed avant de renvoyer ma Property ReturnValue !?
Le test grâce à l'overload de Show: Dim ibUser As String = Nothing
ibUser = InputBox10.Show("Login", "Entrez votre nom d'utilisateur ci-dessous:").ToUpper
Ma question:
Je ne voie pas comment charger ma page avec Show et attendre un retour ?
Le code:
Public Class InputBox10
Property ReturnValue As String = ""
Overloads Shared Function Show(ByVal TitleEx As String, ByVal MessageEx As String, Optional ByVal DefaultValueEx As String = "") As String
With InputBox10
.txtValeur.Text = DefaultValueEx
.labMessage.Text = MessageEx
.Text = TitleEx
End With
AddHandler Form.ActiveForm.FormClosed, AddressOf FormClosed
Return InputBox10.ReturnValue
End Function
Shared Shadows Sub FormClosed()
InputBox10.Close()
End Sub
Private Sub InputBox10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Application.DoEvents()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If txtValeur.TextLength = 0 Then
Me.ReturnValue = Nothing
Else
Me.ReturnValue = txtValeur.Text
End If
OnFormClosed(e)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.ReturnValue = Nothing
OnFormClosed(e)
End Sub
End Class
A voir également:
Problème pour créer un InputBox perso (problème illustré)