Hi
I need the code to copy a file from one location to another.
eg....
C:\myFolder\Myfile to D:\userFolder\UserFileName
Printable View
Hi
I need the code to copy a file from one location to another.
eg....
C:\myFolder\Myfile to D:\userFolder\UserFileName
VB Code:
FileCopy "SourceFile", "DestFile"
hey thanks motoxpro
I'll try that out :)
yes it worked :D
thanks
your welcome
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.
:D
could you show me the code ?
yes hold on let me get it....
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"
:)
VB is getting cooooler
lol....did you get it working?
of course :D
cool,,,,btw what is your progam for?
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
ok cool, if you need any help just tell me
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 ?.
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
that was just an exapleVB Code:
Printer.Print "this is the first page of my book."
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
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
thanks, but can I use it with a database records ?
and one more question :D
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
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:
VB Code:
saveini
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
wait there is a speacal ini i have to give u hole on let me get it in a zip
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
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
np i really just copied it from mine LOL