IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

ComboBox (liste déroulante) en vbs


Sujet :

VBScript

  1. #1
    Membre du Club
    Homme Profil pro
    Inscrit en
    Décembre 2011
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2011
    Messages : 48
    Points : 42
    Points
    42
    Par défaut ComboBox (liste déroulante) en vbs
    Bonjour

    Il y a il une solution pour faire uun ComboBox (liste déroulante) en vbs?
    Merci d'avance

  2. #2
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222
    Par défaut

    Peut-être que oui Testez ce code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    'http://www.ericphelps.com/scripting/samples/Reference/ChooseOne.txt
    Call ChooseOne("Mon 1er Choix/2eme Choix/3eme Choix/4eme Choix/5eme Choix/6eme Choix/7eme choix/8eme choix/9 eme Choix/10 eme Choix")
    Function ChooseOne(strTabDelimitedChoices)
    'Returns one of several string choices. 
    'Returns empty string if there is a problem.
    Dim fs, web, doc
    Dim strFile, strChoice
    Dim intChars
    Dim dtTime
    	On Error Resume Next
    	Set web = CreateObject("InternetExplorer.Application")
    	If web Is Nothing Then
    		ChooseOne = ""
    		Exit Function
    	End If
    	'Increase displayed width to accomodate longest string choice
    	intChars = 0
    	For Each strChoice In Split(strTabDelimitedChoices,"/")
    		If Len(strChoice) > intChars Then intChars = Len(strChoice)
    	Next
    	If intChars > 20 Then
    		web.Width = 250 + 6 * (intChars - 20)
    	Else
    		web.Width = 250
    	End If
    	web.Height = 200
    	web.Offline = True
    	web.AddressBar = False
    	web.MenuBar = False
    	web.StatusBar = False
    	web.Silent = True
    	web.ToolBar = False
    	web.Navigate "about:blank"
    	'Wait for the browser to navigate to nowhere
    	dtTime = Now
    	Do While web.Busy
    		'Don't wait more than 5 seconds
    		Wscript.Sleep 100
    		If (dtTime + 5/24/60/60) < Now Then
    			ChooseOne = ""
    			web.Quit
    			Exit Function
    		End If
    	Loop
    	'Wait for a good reference to the browser document
    	Set doc = Nothing
    	dtTime = Now
    	Do Until Not doc Is Nothing
    		Wscript.Sleep 100
    		Set doc = web.Document
    		'Don't wait more than 5 seconds
    		If (dtTime + 5/24/60/60) < Now Then
    			ChooseOne = ""
    			web.Quit
    			Exit Function
    		End If
    	Loop
    	'Write the HTML form
    	doc.Write "<html><head><title>Choose</title></head>"
    	doc.Write "<body><b>Choose One:</b><br><form><select name=""choice"">"
    	For Each strChoice In Split(strTabDelimitedChoices,"/")
    		doc.Write "<option value=""" & strChoice & """>" & strChoice
    	Next
    	doc.Write "</select>"
    	doc.Write "<br><br><input type=button "
    	doc.Write "name=submit "
    	doc.Write "value=""OK"" onclick='javascript:submit.value=""Done""'>"
    	doc.Write "</form></body></html>"
    	'Show the form
    	web.Visible = True
    	'Wait for the user to choose, but fail gracefully if a popup killer.
    	Err.Clear
    	Do Until doc.Forms(0).elements("submit").Value <> "OK"
    		Wscript.Sleep 100
    		If doc Is Nothing Then
    			ChooseOne = ""
    			web.Quit
    			Exit Function
    		End If
    		If Err.Number <> 0 Then
    			ChooseOne = ""
    			web.Quit
    			Exit Function
    		End If
    	Loop
    	'Retrieve the chosen value
    	ChooseOne = doc.Forms(0).elements("choice").Value
    	web.Quit
    End Function

  3. #3
    Membre du Club
    Homme Profil pro
    Inscrit en
    Décembre 2011
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2011
    Messages : 48
    Points : 42
    Points
    42
    Par défaut [Résolu]
    merci ,c'est une belle combinaison de html et vbs

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2003] ComboBox Liste déroulante - MàJ cellule
    Par jeanpierre78 dans le forum Excel
    Réponses: 1
    Dernier message: 17/03/2014, 09h02
  2. [XL-2007] Synchronisation de 3 combobox listes déroulantes
    Par trycoon dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 09/03/2014, 17h59
  3. [XL-2003] Combobox - Liste déroulante amovible
    Par Chakalaka dans le forum Macros et VBA Excel
    Réponses: 10
    Dernier message: 19/06/2012, 09h48
  4. Création d'une combobox liste déroulante
    Par ThieBEN dans le forum IHM
    Réponses: 14
    Dernier message: 15/11/2007, 09h52
  5. Test sur une ComboBox (Liste déroulante).
    Par SeaWolf601 dans le forum IHM
    Réponses: 5
    Dernier message: 05/10/2006, 17h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo