|
-
Oct 27th, 2001, 01:48 AM
#1
Thread Starter
Addicted Member
Coping
Hi
I need the code to copy a file from one location to another.
eg....
C:\myFolder\Myfile to D:\userFolder\UserFileName
-
Oct 27th, 2001, 01:53 AM
#2
Frenzied Member
VB Code:
FileCopy "SourceFile", "DestFile"
-
Oct 27th, 2001, 02:06 AM
#3
Thread Starter
Addicted Member
hey thanks motoxpro
I'll try that out
-
Oct 27th, 2001, 02:10 AM
#4
Thread Starter
Addicted Member
yes it worked 
thanks
-
Oct 27th, 2001, 02:12 AM
#5
Frenzied Member
-
Oct 27th, 2001, 06:35 AM
#6
FileCopy gets heartburn if the source file already exists in the destination. If your copy needs to overlay and existing file, I would use the CopyFile method of the FileSystemObject.
-
Oct 27th, 2001, 10:42 PM
#7
Thread Starter
Addicted Member

could you show me the code ?
-
Oct 27th, 2001, 10:47 PM
#8
Frenzied Member
yes hold on let me get it....
-
Oct 27th, 2001, 10:54 PM
#9
Frenzied Member
ok, make a refrence to Microsoft Scripting Runtime.
then, you can go like this:
VB Code:
Dim fs as New FileSystemObject
fs.CopyFile "Source", "Dest"
-
Oct 27th, 2001, 11:06 PM
#10
Thread Starter
Addicted Member

VB is getting cooooler
-
Oct 27th, 2001, 11:34 PM
#11
Frenzied Member
lol....did you get it working?
-
Oct 27th, 2001, 11:36 PM
#12
Thread Starter
Addicted Member
of course
-
Oct 27th, 2001, 11:39 PM
#13
Frenzied Member
cool,,,,btw what is your progam for?
-
Oct 28th, 2001, 12:03 AM
#14
Thread Starter
Addicted Member
it's a Inventry handling one with customer credit control and all that stuff. just wanna back up the access db. this is for a small business
-
Oct 28th, 2001, 12:22 AM
#15
Frenzied Member
ok cool, if you need any help just tell me
-
Oct 28th, 2001, 12:45 AM
#16
Thread Starter
Addicted Member
thanks
by the way
I have a problem with crystal reports. I can design the program in crystal reports and print it there. but when I call that file to print from Vb it doesn't print.
and one more thing do I need to install crystal report Spftware on the cleint machine after this is done ?.
-
Oct 28th, 2001, 12:58 AM
#17
Frenzied Member
well, the 2 ways i know to print in VB is
1: use a common diolog
2: use the print object like the code below
VB Code:
Printer.Print "this is the first page of my book."
that was just an exaple
-
Oct 28th, 2001, 01:02 AM
#18
Thread Starter
Addicted Member
I know the second method, but it's bit long , hard and looks old. what's that common dialog ? that is something I havent heard of.
but I have used datareports which is also not the very best
-
Oct 28th, 2001, 01:19 AM
#19
Frenzied Member
here is an exaple of calling the Pint common diolog and setting some of its properties through code:
VB Code:
Private Sub cmdPrint_Click()
On Error GoTo err_handler
dlgCmn.CancelError = True
'set the number of copies and orentation
dlgCmn.Copies = 10
dlgCmn.Orientation = cdLandscape
'show the print common diolog box
dlgCmn.ShowPinter
err_handler:
Msgbox "A printing error occurred", vbExclamation
End Sub
-
Oct 28th, 2001, 01:26 AM
#20
Thread Starter
Addicted Member
thanks, but can I use it with a database records ?
and one more question 
this may sound silly but
I want to save a value in my application. I dont know how to call this value. I'll give you an example.
when you install a new software it asks for a name and company. later you see this name and company when you start the software. like that I want to save some string's and etc on my application. they should be able to change time to time.
and for this saving I dont want to use a databse :d
hope you can understand
-
Oct 28th, 2001, 01:44 AM
#21
Frenzied Member
well really i know nothing about dta base records sorrey and for your other question YEP it took me a while to figure out that 1 2 but here you go:
you need a command button a textbox a form and a ini file
put this in a module:
VB Code:
Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationname As String, ByVal _
lpKeyName As Any, ByVal lsString As Any, _
ByVal lplFilename As String) As Long
Declare Function GetPrivateProfileString Lib _
"kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationname As String, ByVal _
lpKeyName As String, ByVal lpDefault As _
String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As _
String) As Long
then just put these anywhere in your form code:
VB Code:
Private Sub loadini()
Dim lngResult As Long
Dim strFileName
Dim strResult As String * 50
strFileName = App.Path & "\combos.ini" 'Declare your ini file !
lngResult = GetPrivateProfileString(KeySection, _
KeyKey, strFileName, strResult, Len(strResult), _
strFileName)
If lngResult = 0 Then
'An error has occurred
Call MsgBox("An error has occurred while calling the API function", vbExclamation)
Else
KeyValue = Trim(strResult)
End If
End Sub
Private Sub saveini()
Dim lngResult As Long
Dim strFileName
strFileName = App.Path & "\combos.ini" 'Declare your ini file !
lngResult = WritePrivateProfileString(KeySection, _
KeyKey, KeyValue, strFileName)
If lngResult = 0 Then
'An error has occurred
Call MsgBox("An error has occurred while calling the API function", vbExclamation)
End If
End Sub
and then create a command button or u can do it in the load form or anything u want:
and then i would but thin in the form load if i were u:
VB Code:
KeySection = "UserNames"
KeyKey = "TextBox1"
loadini
txtGetDir.Text = KeyValue
KeySection = "UserNames"
KeyKey = "TextBox2"
loadini
Text1.Text = KeyValue
-
Oct 28th, 2001, 01:45 AM
#22
Frenzied Member
wait there is a speacal ini i have to give u hole on let me get it in a zip
-
Oct 28th, 2001, 01:51 AM
#23
Frenzied Member
ok what this does is save the text from the text bob to an ini file and when the form loads it will load the data that was in the textbox that is saved to the ini
-
Oct 28th, 2001, 02:10 AM
#24
Thread Starter
Addicted Member
phew that was some code 
thanks yadi dadi :d
I'll try this out. I'm pretty sure this would tkae some time )
thanks again
-
Oct 28th, 2001, 02:21 AM
#25
Frenzied Member
np i really just copied it from mine LOL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|