Inputbox + parcourir

manud31 Messages postés 81 Date d'inscription vendredi 28 octobre 2005 Statut Membre Dernière intervention 16 mai 2006 - 19 janv. 2006 à 17:25
Shark-Man Messages postés 22 Date d'inscription jeudi 23 octobre 2003 Statut Membre Dernière intervention 7 octobre 2006 - 18 févr. 2006 à 15:56
Hello !!!


Je souhaiterais aller récupérer un fichier via un input box et un bouton parcourir, comment puis-je le faire ?


Et après faut-il que je donne une variable au fichier récupéré afin de m’en servir dans une exécution ?

@+

3 réponses

Simouss33 Messages postés 85 Date d'inscription jeudi 17 novembre 2005 Statut Membre Dernière intervention 15 février 2006 2
19 janv. 2006 à 18:01
Tu programmes en quoi? Qu'est-ce que tu veux dire exactement par aller récupérer un fichier via un input box et un bouton parcourir parce que je ne comprends pas très bien?
0
manud31 Messages postés 81 Date d'inscription vendredi 28 octobre 2005 Statut Membre Dernière intervention 16 mai 2006
19 janv. 2006 à 18:21
je programme en VB6
ce que je veux faire c'est aller récupérer un fichier grâce à une input box
et dans cette input box il y aurait un bouton parcourir qui aurait la même fonction qu'un bouton parcourir normal sous windows
et en cliquant sur le bouton parcourir j'irai recupere mon fichier dans mes documents

@+
0
Shark-Man Messages postés 22 Date d'inscription jeudi 23 octobre 2003 Statut Membre Dernière intervention 7 octobre 2006
18 févr. 2006 à 15:56
Hm j'ai pas vraiment tout compris non plus.

Je te conseil de laisser tomber l'idée de l'input box et de creer toi
même une form tu poura en faire ce que tu veux précisément.



Pour récuperer le chemin d'un dossier avec une box:




Private Declare Function
ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As
Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As
Long

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)
As Long

Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long



Private Const BIF_RETURNONLYFSDIRS = &H1



Private Type BROWSEINFO

hOwner As Long

pidlRoot As Long

pszDisplayName As String

lpszTitle As String

ulFlags As Long

lpfn As Long

lParam As Long

iImage As Long

End Type





Private Sub Command1_Click()

Dim X As BROWSEINFO

Dim Chemin As String

Dim Repertoire

Dim pidl As Long

Dim RetVal As Long

Dim p As Integer



X.hOwner = Me.hwnd

X.pidlRoot = 0&

X.lpszTitle = "Repertoire cible:"

X.ulFlags = BIF_RETURNONLYFSDIRS

pidl& = SHBrowseForFolder(X)



Chemin = String(512, 0)

RetVal = SHGetPathFromIDList(pidl&, Chemin)

If RetVal Then

p = InStr(Chemin, Chr$(0))

Repertoire = Left(Chemin, p - 1)

End If

End Sub



Ce code n'est pas de moi, il est extrait de "Clm's
Recherche" disponnible en source sur ce site (je ne me souviens plus du
lien désolé).



Si tu veux récuperer le chemin d'un fichier, commence par rajouter le
composant Microsoft Common Dialog 6.0 et dans ta forme le controle
Common Dialog.

Ensuite:

Dim strTonChemin As String

Private Sub Mnu_Ouvrir_Click()

'on donne le propriétés de la boite de dial

Cdlg.Filter = "Fichier texte (*.txt)|*.txt|Tous les fichiers (*.*)|*.*" 'par exemple

'on affiche la boite

Cdlg.ShowOpen

If Cdlg.FileName <> "" Then

strTonChemin = Cdlg.FileName

End If

End Sub



J'espère que c'est ce que tu voulais.

Bonne contituation.


° The world is moving so fast these days that the person who says it can't be done is generally interrupted by someone doing it ° Harry Emerson Fosdick
0
Rejoignez-nous