?
Solved

Autosend a file in a directory.

Posted on 2003-03-19
6
Medium Priority
?
175 Views
Last Modified: 2010-05-01
I would like to autosend a file that is created in a directory (A) to another directory (B) in every 1 minute.

I already have a send file program for visual basic. Can someone help me add the above function into my program below.

In the first buttons click event:
   With Me.CommonDialog1
       .DialogTitle = "Choose File:"
       .InitDir = App.Path
       .ShowOpen
   End With
   
   If Me.CommonDialog1.FileName <> "" Then
       Me.List1.AddItem Me.CommonDialog1.FileName
   End If

In the second buttons click event:

In the second buttons click event:
'there is a better way to do this with the API, but
'this is easier.

   With Me.CommonDialog1
       .DialogTitle = "Choose Send To Path:"
       .InitDir = App.Path
       .FileName = "x"
       .ShowOpen
   End With
   
   If Me.CommonDialog1.FileName <> "" Then
       Me.Label1.Caption = Mid(Me.CommonDialog1.FileName, 1, InStrRev(Me.CommonDialog1.FileName, "\"))
   End If

In the third buttons click event do either:
Dim iItem as integer
Dim strFile as string

For iItem = Me.List1.ListCount - 1 To 0 Step -1
    strFile = Dir(Me.List1.List(iItem))
    FileCopy Me.List1.List(iItem), Me.Label1.Caption & strFile
    Kill Me.List1.List(iItem)
    Me.List1.RemoveItem (iItem)
Next iItem
0
Comment
Question by:elyn_09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Expert Comment

by:DocM
ID: 8171145
Hi,
The first button and the second button are OK.

Add a Timer control to your form.

Private Sub Timer1_Timer()

 Dim iItem as integer
 Dim strFile as string

 For iItem = Me.List1.ListCount - 1 To 0 Step -1
   strFile = Dir(Me.List1.List(iItem))
   FileCopy Me.List1.List(iItem), Me.Label1.Caption &  strFile
   Kill Me.List1.List(iItem)
   Me.List1.RemoveItem (iItem)
 Next iItem

End Sub

In the third buttons click event do either:

 Timer1.Interval = 60000
 Timer1.Enabled = True
0
 

Author Comment

by:elyn_09
ID: 8171284
I tried. Its not the program i wanted. I wanted a program that can autosend the file ( maybe lets say a file named ABC.txt ) created in directory A to directory B. Thats all.
0
 
LVL 3

Accepted Solution

by:
DocM earned 200 total points
ID: 8171592
OK then. Try this code. Put 2 Label controls, 2 Command controls and one Timer control.

Private Sub Command1_Click()
    Label1.Caption = ""
    With CommonDialog1
        .DialogTitle = "Choose File:"
        .InitDir = App.Path
        .ShowOpen
    End With
    If CommonDialog1.FileName <> "" Then
        Label1.Caption = CommonDialog1.FileName
    End If
End Sub

Private Sub Command2_Click()
    With Me.CommonDialog1
        .DialogTitle = "Choose Send To Path:"
        .InitDir = App.Path
        .FileName = "x"
        .ShowOpen
    End With
    If Me.CommonDialog1.FileName <> "" Then
        Me.Label2.Caption = Mid(Me.CommonDialog1.FileName, 1, InStrRev(Me.CommonDialog1.FileName, "\"))
    End If
End Sub

Private Sub Form_Load()
    Timer1.Interval = 60000
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    On Error GoTo ErrorHandling
    If Dir(Label1.Caption) <> "" Then
        If Label2.Caption <> "" Then
            FileName = Mid(Label1.Caption, InStrRev(Label1.Caption, "\") + 1)
            Path = Label2.Caption
            If Right(Path, 1) <> "\" Then Path = Path & "\"
            FileCopy Label1.Caption, Path & FileName
            Kill Label1.Caption
        End If
    End If
    Exit Sub
ErrorHandling:
    MsgBox "Error :" & Err.Number & " - " & Err.Description
End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:CleanupPing
ID: 8531966
Hi elyn_09,
This old question (QID 20556839) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8982632
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in a week or two.  I would appreciate any comments by the experts that would help me in making a recommendation.
It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp

GPrentice00
Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9046074
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept DocM's comment as Answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question