Problème pour créer un InputBox perso (problème illustré)

Résolu
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 - 15 janv. 2011 à 18:50
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 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

3 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
15 janv. 2011 à 19:41
salut,

normal ta form n'est pas MODAL

voir showdialog

ps : pourquoi ne pas passer par le formclosed natif?

++
[hr]
3
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
15 janv. 2011 à 20:58
Je prépare une source pour partager une base Inputbox VB10 et je post le lien ici.

Merci pour l'indice "ShowDialog" PCPT ^^
0
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
15 janv. 2011 à 21:24
0
Rejoignez-nous