Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

input box et annuler

6 réponses
Avatar
dav
j'utilise un inputBox comme ceci :

mot = InputBox("mot recherché :")

comment récupérer le clic de l'utilisateur sur "annuler" et de ce fait
ne pas effectuer l'opération demander....avec MsgBox je vois bien
VbAbort ou VbCancel :

if MsgbOx = VbCancel then....

mais avec InputBox ?????? quand je clic sur annuler l'opréation se fait
quand meme...

merci
dav

6 réponses

Avatar
O'Hare Benoît
salut
tu teste si tu retourne bien qqch

if len(toto = inputbox("")) <> 0 then
msgbox toto
end if

Cordialement

"dav" a écrit dans le message de
news:41597f8e$0$27394$
j'utilise un inputBox comme ceci :

mot = InputBox("mot recherché :")

comment récupérer le clic de l'utilisateur sur "annuler" et de ce fait
ne pas effectuer l'opération demander....avec MsgBox je vois bien
VbAbort ou VbCancel :

if MsgbOx = VbCancel then....

mais avec InputBox ?????? quand je clic sur annuler l'opréation se fait
quand meme...

merci
dav


Avatar
dav
O'Hare Benoît a écrit :

salut
tu teste si tu retourne bien qqch

if len(toto = inputbox("")) <> 0 then
msgbox toto
end if

Cordialement

"dav" a écrit dans le message de
news:41597f8e$0$27394$

j'utilise un inputBox comme ceci :

mot = InputBox("mot recherché :")

comment récupérer le clic de l'utilisateur sur "annuler" et de ce fait
ne pas effectuer l'opération demander....avec MsgBox je vois bien
VbAbort ou VbCancel :

if MsgbOx = VbCancel then....

mais avec InputBox ?????? quand je clic sur annuler l'opréation se fait
quand meme...

merci
dav








mais avec InputBox, y'a bien moyen de tester si on a cliqué sur Ok ou
sur ANNULER ? non ?

merci,
dav
Avatar
LE TROLL
Salut,

Ben de mémoire, non, il n'y a pas de différence soit c'est plein (la
chaîne), soit c'est vide... De facto le VbCancel fonctionnerait dans le cas
d'un Msgbox, mais pas d'un InputBox...

Pour y remédier: une form, 3 bouton + un TextBox, ce qui ne bloque pas
le programme...

"dav" a écrit dans le message de
news:415988b6$0$14640$
O'Hare Benoît a écrit :

> salut
> tu teste si tu retourne bien qqch
>
> if len(toto = inputbox("")) <> 0 then
> msgbox toto
> end if
>
> Cordialement
>
> "dav" a écrit dans le message de
> news:41597f8e$0$27394$
>
>>j'utilise un inputBox comme ceci :
>>
>>mot = InputBox("mot recherché :")
>>
>>comment récupérer le clic de l'utilisateur sur "annuler" et de ce fait
>>ne pas effectuer l'opération demander....avec MsgBox je vois bien
>>VbAbort ou VbCancel :
>>
>>if MsgbOx = VbCancel then....
>>
>>mais avec InputBox ?????? quand je clic sur annuler l'opréation se fait
>>quand meme...
>>
>>merci
>>dav
>
>
>

mais avec InputBox, y'a bien moyen de tester si on a cliqué sur Ok ou
sur ANNULER ? non ?

merci,
dav


Avatar
Alain CROS
Bonjour.

Copie d'un post paru ici même.

Alain CROS


Differentiating Between Cancel and OK/No Value in an InputBox
http://vbnet.mvps.org/index.html?code/helpers/inputbox.htm

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2004 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()

Dim sInput As String

sInput = InputBox("Go ahead ... abuse me", _
"Dreaded InputBox Demo", _
"Some default text goes here")

If StrPtr(sInput) = 0 Then

MsgBox "Cancel was pressed"

Else

If Len(sInput) = 0 Then
MsgBox "OK pressed but nothing entered."
Else
MsgBox "OK pressed: value= " & sInput
End If 'Len(sInput)

End If 'StrPtr

End Sub

--
Pierre ALEXIS - MVP Visual Basic
Courriel & messenger :
FAQ Visual Basic : http://faq.vb.free.fr/

mais avec InputBox, y'a bien moyen de tester si on a cliqué sur Ok ou
sur ANNULER ? non ?

merci,
dav


Avatar
LE TROLL
Ouais... mais le problème c'est que le résultat est lu dans la chaîne de
saisie je crois, alors si tu tapes "0", ben...


"Alain CROS" a écrit dans le message de
news:%
Bonjour.

Copie d'un post paru ici même.

Alain CROS


Differentiating Between Cancel and OK/No Value in an InputBox
http://vbnet.mvps.org/index.html?code/helpers/inputbox.htm

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2004 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()

Dim sInput As String

sInput = InputBox("Go ahead ... abuse me", _
"Dreaded InputBox Demo", _
"Some default text goes here")

If StrPtr(sInput) = 0 Then

MsgBox "Cancel was pressed"

Else

If Len(sInput) = 0 Then
MsgBox "OK pressed but nothing entered."
Else
MsgBox "OK pressed: value= " & sInput
End If 'Len(sInput)

End If 'StrPtr

End Sub

--
Pierre ALEXIS - MVP Visual Basic
Courriel & messenger :
FAQ Visual Basic : http://faq.vb.free.fr/

> mais avec InputBox, y'a bien moyen de tester si on a cliqué sur Ok ou
> sur ANNULER ? non ?
>
> merci,
> dav




Avatar
LE TROLL
Autant pour moi "mea culpa", StrPtr(i), ok, ça prend la valeur de la
réponse...


"LE TROLL" <le a écrit dans le message de
news:
Ouais... mais le problème c'est que le résultat est lu dans la chaîne de
saisie je crois, alors si tu tapes "0", ben...


"Alain CROS" a écrit dans le message de
news:%
> Bonjour.
>
> Copie d'un post paru ici même.
>
> Alain CROS
>
>
> Differentiating Between Cancel and OK/No Value in an InputBox
> http://vbnet.mvps.org/index.html?code/helpers/inputbox.htm
>
> Option Explicit
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Copyright ©1996-2004 VBnet, Randy Birch, All Rights Reserved.
> ' Some pages may also contain other copyrights by the author.
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Distribution: You can freely use this code in your own
> ' applications, but you may not reproduce
> ' or publish this code on any web site,
> ' online service, or distribute as source
> ' on any media without express permission.
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> Private Sub Command1_Click()
>
> Dim sInput As String
>
> sInput = InputBox("Go ahead ... abuse me", _
> "Dreaded InputBox Demo", _
> "Some default text goes here")
>
> If StrPtr(sInput) = 0 Then
>
> MsgBox "Cancel was pressed"
>
> Else
>
> If Len(sInput) = 0 Then
> MsgBox "OK pressed but nothing entered."
> Else
> MsgBox "OK pressed: value= " & sInput
> End If 'Len(sInput)
>
> End If 'StrPtr
>
> End Sub
>
> --
> Pierre ALEXIS - MVP Visual Basic
> Courriel & messenger :
> FAQ Visual Basic : http://faq.vb.free.fr/
>
> > mais avec InputBox, y'a bien moyen de tester si on a cliqué sur Ok ou
> > sur ANNULER ? non ?
> >
> > merci,
> > dav
>
>