CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    23

    Command button with timer

    Hi;

    I have n button that executes the application obviously, but what I want to do is set a timer so that the timer
    execute the application every 15 minutes so I don’t know how to link the command button to the timer if it is possible


    Code:
    Private Sub cmdstart_Click()

    If lblMsgA >= 1000 Then
    Dim oleasApp As Outlook.Application
    Set oleasApp = CreateObject("Outlook.Application")

    Dim oleasNs As Outlook.Namespace
    Set oleasNs = oleasApp.GetNamespace("MAPI")
    oleasNs.Logon

    Dim oleasMail As Outlook.MailItem
    Set oleasMail = oleasApp.CreateItem(oleasMailItem)

    oleasMail.To = " @ "
    oleasMail.Subject = "VB TEST"
    oleasMail.Body = _
    "Bla Bla" & ", " & vbCr & vbCr & vbTab & _
    "Bla ." & ", " & vbCr & vbCr & vbTab & _
    "Bla"
    oleasMail.Send

    MsgBox "All done...", vbMsgBoxSetForeground
    oleasNs.Logoff
    Set oleasNs = Nothing
    Set oleasMail = Nothing
    Set oleasApp = Nothing
    End If

    ‘Timer’
    Dim MinCount As Integer()
    Sub tmrMinute_Timer()
    MinCount = MinCount + 1
    If (MinCount = 15) Then
    cmdstart ( DON’T KNOW THIS PART CAN IT BE DONE like this..
    MinCount = 0
    End If
    End Sub

  2. #2
    Join Date
    Oct 2009
    Posts
    12

    Re: Command button with timer

    dear, can this help?

    form with : command = cmdstart
    timer1 and label1

    !! set timer1 Interval to 1000 millisec. ( = 1 sec.) as fast control !!!
    ===================================
    Option Explicit
    Dim MinCount As Integer

    Private Sub cmdstart_Click()

    If lblMsgA >= 1000 Then
    Dim oleasApp As Outlook.Application
    Set oleasApp = CreateObject("Outlook.Application")

    Dim oleasNs As Outlook.Namespace
    Set oleasNs = oleasApp.GetNamespace("MAPI")
    oleasNs.Logon

    Dim oleasMail As Outlook.MailItem
    Set oleasMail = oleasApp.CreateItem(oleasMailItem)

    oleasMail.To = " @ "
    oleasMail.Subject = "VB TEST"
    oleasMail.Body = _
    "Bla Bla" & ", " & vbCr & vbCr & vbTab & _
    "Bla ." & ", " & vbCr & vbCr & vbTab & _
    "Bla"
    oleasMail.Send

    MsgBox "All done...", vbMsgBoxSetForeground
    oleasNs.Logoff
    Set oleasNs = Nothing
    Set oleasMail = Nothing
    Set oleasApp = Nothing
    End If
    End Sub

    Sub tmrMinute_Timer()
    '§ set timer1 Interval=min. => 60000 millisec. !!
    MinCount = MinCount + 1
    '§ as temporary control
    Label1.Caption = MinCount
    If (MinCount = 15) Then
    Call cmdstart_Click
    MinCount = 0
    End If
    End Sub


    ===================================
    Attached Files Attached Files

  3. #3
    Join Date
    Sep 2009
    Posts
    23

    Re: Command button with timer

    Thanks got confuse with the “Call cmdstart_Click” part

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

Featured