how would i make a file name show up in a textbox and it u clicked it it would go to the file like if i wanted to copy it to a dif dir
Printable View
how would i make a file name show up in a textbox and it u clicked it it would go to the file like if i wanted to copy it to a dif dir
Do you know the location of the file?
If so, just do this: Text1.text = "C:\YourFile"
If you don't know, use a common dialog box control
and to copy, use the FileCopy function.
how would i load all the file names in a 1 dir.....beacause all urs does is make text show up
HEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLPPP!!!!!!!!!!!!!!!
Why not use a FileListBox ?
It will show u all files in a given folder, and that is what u want ? or?
HELP!!!!!!!!!!!
no not like that i mean get all the files to show up in a textbox and be able to select amy1 of thos files and copy r delete it
well u should not use a textbox.
use a listbox
try this
VB Code:
Option Explicit Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) As Long Private Const LB_DIR = &H18D Private Const DDL_READWRITE = &H0 Private Const DDL_READONLY = &H1 Private Const DDL_HIDDEN = &H2 Private Const DDL_SYSTEM = &H4 Private Const DDL_DIRECTORY = &H10 Private Const DDL_ARCHIVE = &H20 Private Const DDL_DRIVES = &H4000 Private Const DDL_EXCLUSIVE = &H8000 Private Const DDL_POSTMSGS = &H2000 Private Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY Or DDL_HIDDEN Or DDL_SYSTEM Private Sub Command1_Click() Dim r As Long r = SendMessageStr(List1.hwnd, LB_DIR, DDL_FLAGS, "C:\*.*") End Sub Private Sub List1_Click() MsgBox List1.Text End Sub
code dont work and i mean i dont want a list box look ill c if i can explain it to u a little better
ok u have a textbox right? and now all i want to do is load the fille names in from a folder.. say i put my exe in the folder and wanted to load all the file names in that folder into the textbox in my exe. i wanted it to be where i could click the load button my my exe and it would load all the file names in that folder in the textbox in my exe.,, then i would be able to select any 1 of thos file names and copy it to another dir or delete it all together.......if u still dont get it tll em
or maybe i should u a lable insted of a text box
thx
Ok, still not sure I understand,(I'm a bit slow :) )
This will add all files found in a given folder to a textbox
VB Code:
Private Sub Command1_Click() Dim sFile As String Dim s As String sFile = Dir(App.Path & "\") Do While sFile <> "" s = s & sFile & vbCrLf sFile = Dir Loop Text1.Text = s End Sub
make sure that the textbox multiline prop is sat to true
is that how u want it?
hmm... the picture is not shown ?
ok thats is....but can i do that with a label and can u make it where it would be like
filename.*
filename.*
filename.*
u c what i am saying and could u make it where i could click on the filename and be able to delete it and copy it
and i think i will make that textbox in the pic a label
OPPPPPPPS i was supsed to use lstbox sry man i think i found some code:
Use a listbox and fill it on form load:
Private Sub Form_Load()
Dim strfile As String
strfile = Dir$("C:\My Documents\*.*")
Do While strfile <> ""
List1.AddItem strfile
strfile = Dir$()
Loop
End Sub
To use the files, select from the listbox
Private Sub List1_Click()
Dim strfile As String
strfile = List1.Text
' to delete
Kill (strfile)
'to copy
'You will need to supply the path
FileCopy strfile, "Copy of " & strFile
End Sub
heh glad u realized :D
the sample I posted earlier will aslo do the trick
u said it didn't work, but it does. U must have done something wrong :)VB Code:
Option Explicit Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) As Long Private Const LB_DIR = &H18D Private Const DDL_READWRITE = &H0 Private Const DDL_READONLY = &H1 Private Const DDL_HIDDEN = &H2 Private Const DDL_SYSTEM = &H4 Private Const DDL_DIRECTORY = &H10 Private Const DDL_ARCHIVE = &H20 Private Const DDL_DRIVES = &H4000 Private Const DDL_EXCLUSIVE = &H8000 Private Const DDL_POSTMSGS = &H2000 Private Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY Or DDL_HIDDEN Or DDL_SYSTEM Private Sub Command1_Click() Dim r As Long r = SendMessageStr(List1.hwnd, LB_DIR, DDL_FLAGS, "C:\*.*") End Sub Private Sub List1_Click() MsgBox List1.Text End Sub
where do i post the top part of u code? :confused:
U should put it in the General Declarations area of u'r form
ie at the top in the code view of a form.
or u can declare it as public and place it in a module :)
awwww man that code is GREAT just what i needed now all i have to do is figure out how to make it like if i select a file in there i would be able to copy it
VB Code:
Option Explicit Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) As Long Private Const LB_DIR = &H18D Private Const DDL_READWRITE = &H0 Private Const DDL_READONLY = &H1 Private Const DDL_HIDDEN = &H2 Private Const DDL_SYSTEM = &H4 Private Const DDL_DIRECTORY = &H10 Private Const DDL_ARCHIVE = &H20 Private Const DDL_DRIVES = &H4000 Private Const DDL_EXCLUSIVE = &H8000 Private Const DDL_POSTMSGS = &H2000 Private Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY Or DDL_HIDDEN Or DDL_SYSTEM Private sFileToCopy As String Private sPath As String Private Sub Command1_Click() Dim r As Long sPath = "C:\DATA\DOCS\" r = SendMessageStr(List1.hwnd, LB_DIR, DDL_FLAGS, sPath & "*.DOC") End Sub Private Sub Command2_Click() 'copy the file :) FileCopy sPath & List1.Text, "C:\TMP\" & List1.Text End Sub
i cant get that 1 to work says path not foun even if i put like FileCopy sPath & List1.Text, "C:\" & List1.Text like that
peet u there?
C:\
nm i was tryin to copy b4 i loaaded the files in silly me :) but now when i try to load the files in nothing shows up in the list box
send me the code, and I'll have a look or just upload the code here :)
ok i got every thing working now hust to add the fiishing tuches.......how would i make it where u could find ur own dir to load the files from.....beacuase the peeps m giving it to arnt gunna have the code :( and how would i make it cut instead of copy and how would i make it where u ould select 1 of thos files and delete it thx man if u answer thse this all the questions i have for this prograam thx
VB Code:
Option Explicit Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) As Long Private Const LB_DIR = &H18D Private Const DDL_READWRITE = &H0 Private Const DDL_READONLY = &H1 Private Const DDL_HIDDEN = &H2 Private Const DDL_SYSTEM = &H4 Private Const DDL_DIRECTORY = &H10 Private Const DDL_ARCHIVE = &H20 Private Const DDL_DRIVES = &H4000 Private Const DDL_EXCLUSIVE = &H8000 Private Const DDL_POSTMSGS = &H2000 Private Const DDL_FLAGS = DDL_ARCHIVE Or DDL_DIRECTORY Or DDL_HIDDEN Or DDL_SYSTEM Private sFileToCopy As String Private sPath As String Private Sub Check1_Click() End Sub Private Sub Check2_Click() End Sub Private Sub Command1_Click() 'copy the file FileCopy "C:\Program Files\Mx Track Pro\Unloaded\" & List1.Text, "D:\MCM2\TERAFORM\NATIONAL\" & List1.Text End Sub Private Sub Command2_Click() Dim r As Long sPath = "D:\MCM2\TERAFORM\NATIONAL\" r = SendMessageStr(List1.hwnd, LB_DIR, DDL_FLAGS, sPath & "*.env") End Sub Private Sub Command3_Click() End Sub Private Sub Command4_Click() 'copy the file FileCopy sPath & List1.Text, "C:\Program Files\Mx Track Pro\Unloaded\" & List1.Text End Sub Private Sub Command5_Click() End Sub Private Sub Command6_Click() FileLen ("C:\Program Files\Mx Track Pro\Unloaded\1tall.env") End Sub Private Sub Command7_Click() Unload Me End Sub Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single) End Sub Private Sub List1_Click() End Sub
that is the whole program......still debugging a little :)
i
oppss i pushed submit....but is that what u want
peet u there??
Use chdir to change your current directory to the directory you want to search for.Quote:
Originally posted by Motoxpro
how would i load all the file names in a 1 dir.....beacause all urs does is make text show up
Than call dir("*.*") for searching files, it will return the first file name under current dir, and you can call it continue with no parameters for getting next filename.
have u read the post i aready got all the code for that
peet u there man......been 2 days
jepp ... I'm here, how far in u'r dev. are u now?
well im pretty much done now but i did the layout a little difernt and i make a text box and a button so u could just type in the right dir there.......only thing now is how to get it to reset like if i try to load 2 dirs the 2nd 1 i load will be right after the first 1 and i want it to reset.......and.....how would imake check boxes acualy work
because i got most all the stuff working and everey thing just need to add the finishing tuches like i said :) :) :D :p :)