Results 1 to 25 of 25

Thread: Coping

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158

    Coping

    Hi

    I need the code to copy a file from one location to another.

    eg....

    C:\myFolder\Myfile to D:\userFolder\UserFileName
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  2. #2
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    VB Code:
    1. FileCopy "SourceFile", "DestFile"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    hey thanks motoxpro

    I'll try that out
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    yes it worked

    thanks
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  5. #5
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    your welcome

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158


    could you show me the code ?
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  8. #8
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    yes hold on let me get it....

  9. #9
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    ok, make a refrence to Microsoft Scripting Runtime.

    then, you can go like this:
    VB Code:
    1. Dim fs as New FileSystemObject
    2. fs.CopyFile "Source", "Dest"

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158


    VB is getting cooooler
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  11. #11
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    lol....did you get it working?

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    of course
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  13. #13
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    cool,,,,btw what is your progam for?

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    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
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  15. #15
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    ok cool, if you need any help just tell me

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    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 ?.
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  17. #17
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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:
    1. Printer.Print  "this is the first page of my book."
    that was just an exaple

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    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
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  19. #19
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    here is an exaple of calling the Pint common diolog and setting some of its properties through code:
    VB Code:
    1. Private Sub cmdPrint_Click()
    2. On Error GoTo err_handler
    3.      dlgCmn.CancelError = True
    4.  
    5.  
    6.       'set the number of copies and orentation
    7.        dlgCmn.Copies = 10
    8.         dlgCmn.Orientation = cdLandscape
    9.  
    10.        'show the print common diolog box
    11.        dlgCmn.ShowPinter
    12. err_handler:
    13.       Msgbox "A printing error occurred", vbExclamation
    14. End Sub

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    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
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  21. #21
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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:
    1. Declare Function WritePrivateProfileString _
    2. Lib "kernel32" Alias "WritePrivateProfileStringA" _
    3. (ByVal lpApplicationname As String, ByVal _
    4. lpKeyName As Any, ByVal lsString As Any, _
    5. ByVal lplFilename As String) As Long
    6.  
    7. Declare Function GetPrivateProfileString Lib _
    8. "kernel32" Alias "GetPrivateProfileStringA" _
    9. (ByVal lpApplicationname As String, ByVal _
    10. lpKeyName As String, ByVal lpDefault As _
    11. String, ByVal lpReturnedString As String, _
    12. ByVal nSize As Long, ByVal lpFileName As _
    13. String) As Long


    then just put these anywhere in your form code:

    VB Code:
    1. Private Sub loadini()
    2.  
    3. Dim lngResult As Long
    4. Dim strFileName
    5. Dim strResult As String * 50
    6. strFileName = App.Path & "\combos.ini" 'Declare your ini file !
    7. lngResult = GetPrivateProfileString(KeySection, _
    8. KeyKey, strFileName, strResult, Len(strResult), _
    9. strFileName)
    10. If lngResult = 0 Then
    11. 'An error has occurred
    12. Call MsgBox("An error has occurred while calling the API function", vbExclamation)
    13. Else
    14. KeyValue = Trim(strResult)
    15. End If
    16.  
    17. End Sub
    18. Private Sub saveini()
    19.  
    20. Dim lngResult As Long
    21. Dim strFileName
    22. strFileName = App.Path & "\combos.ini" 'Declare your ini file !
    23. lngResult = WritePrivateProfileString(KeySection, _
    24. KeyKey, KeyValue, strFileName)
    25. If lngResult = 0 Then
    26. 'An error has occurred
    27. Call MsgBox("An error has occurred while calling the API function", vbExclamation)
    28. End If
    29.  
    30. End Sub

    and then create a command button or u can do it in the load form or anything u want:
    VB Code:
    1. saveini

    and then i would but thin in the form load if i were u:
    VB Code:
    1. KeySection = "UserNames"
    2. KeyKey = "TextBox1"
    3. loadini
    4. txtGetDir.Text = KeyValue
    5.  
    6. KeySection = "UserNames"
    7. KeyKey = "TextBox2"
    8. loadini
    9. Text1.Text = KeyValue

  22. #22
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    wait there is a speacal ini i have to give u hole on let me get it in a zip

  23. #23
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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

  24. #24

    Thread Starter
    Addicted Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    158
    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
    [vbcode] On Error GoTo VBForums[/vbcode]
    www27.brinkster.com/muditha

  25. #25
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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
  •  



Click Here to Expand Forum to Full Width