Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

An Array Maybe?

Posted on 1999-09-14
9
Medium Priority
?
143 Views
Last Modified: 2010-05-02
Howdy:) This is my first time here. I am a beginner in visual basic and am using 5.0 The code below works fine. My problem is that I want the code to fire off more than one "pic.bmp" without overwriting. Is there a way to write this so that I don't have to repeat it 10 times one after the other (told you i was a beginner)? I also would like to know if there is a way to change the ""DateAdd("s", 30, Now)"" so that a user could select their own time in "s" for seconds, "n" for minutes etc. I think this should be enough for now. Please submit some working code for the incomplete idiot !
I don't know how much this question is worth, but I received 75 Points when I joined up here. Hope this is enough ?
snagg

Dim CheckTyme As Date
    CheckTyme = DateAdd("s", 30, Now)
    Do Until Now > CheckTyme
       DoEvents
       Loop
    Set Picture1.Picture = CaptureScreen()
    SavePicture Picture1.Picture, "C:\Save\pic1.bmp"
0
Comment
Question by:snagg
[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
  • 4
  • 4
9 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 320 total points
ID: 2047046
'Have the user select a Timer1.Interval form 1000 to 65000
'(1 second to 65 seconds) in a ComboBox or TextBox control
'When the Timer is enabled, it will save the new file to disk
'with a unique filename.  It will overwrite when the program is restarted
'unless you save i in a global variable using SaveSetting and GetSetting

Private Sub Timer1_Timer()
    Static i As Integer
    Dim szFileName As String
   
    Set Picture1.Picture = CaptureScreen()
    'Create a new file name
    szFileName = "c:\save\pic" & Str(i) & ".bmp"
    SavePicture Picture1.Picture, szFileName
    i = i + 1
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2047056
Or a unique filename can be derived from the time.

szFileName = Format(Now, "mmddhhmmss") & ".bmp"
0
 

Author Comment

by:snagg
ID: 2048423
Erick37, As per your above statement: 'Have the user select a Timer1.Interval form 1000 to 65000 '(1 second to 65 seconds) in a ComboBox or TextBox control 'When the Timer is enabled, it will save the new file to disk 'with a unique filename.  It will overwrite when the program is restarted 'unless you save i in a global variable using SaveSetting and GetSetting

I am interested in doing it this way but don't know how. Could you work me up some code to do it this way ? I am giving you the 5 points I made today also !
snagg    
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:snagg
ID: 2048427
Erick37, As per your above statement: 'Have the user select a Timer1.Interval form 1000 to 65000 '(1 second to 65 seconds) in a ComboBox or TextBox control 'When the Timer is enabled, it will save the new file to disk 'with a unique filename.  It will overwrite when the program is restarted 'unless you save i in a global variable using SaveSetting and GetSetting

I am interested in doing it this way but don't know how. Could you work me up some code to do it this way ? I am giving you the 5 points I made today also !
snagg    
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2048747
'Simple program to save images to file at user selected
'intervals.  Place a timer, a pixture box  and a
'combo box on form1.

Option Explicit

Private szPath As String
Private szFileName As String
Private szFileExt As String

Private Sub Combo1_Click()
    'Change the timer interval when the user
    'selects a new value
    Timer1.Interval = Combo1.ItemData(Combo1.ListIndex)
End Sub

Private Sub Form_Load()
    'Populate the Combo box with Names and values
    With Combo1
        'Text that is displayed
        .AddItem "Disabled"
        'Value associated with the above item
        .ItemData(.NewIndex) = 0
        .AddItem "60 sec"
        .ItemData(.NewIndex) = 60000
        .AddItem "50 sec"
        .ItemData(.NewIndex) = 50000
        .AddItem "40 sec"
        .ItemData(.NewIndex) = 40000
        .AddItem "30 sec"
        .ItemData(.NewIndex) = 30000
        .AddItem "20 sec"
        .ItemData(.NewIndex) = 20000
        .AddItem "10 sec"
        .ItemData(.NewIndex) = 10000
        .AddItem "5 sec"
        .ItemData(.NewIndex) = 5000
        .AddItem "1 sec"
        .ItemData(.NewIndex) = 1000
        .ListIndex = 0
    End With
    'Change to suit your needs:
    szPath = "c:\"
    szFileExt = ".bmp"
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    'Set Picture1.Picture = CaptureScreen()
    'Create a new file name based on date
    szFileName = szPath & Format(Now, "mmddhhmmss") & szFileExt
    SavePicture Picture1.Picture, szFileName
    Debug.Print szFileName; " Saved"
End Sub
0
 

Author Comment

by:snagg
ID: 2049077
Erick37, Hey, looks real good now that i see it. I can't get it to do anything though ? I select a time from the combo, it highlights it but will not do anything. Should i place a command button on the form ? If so, what do i have it do ?
Yeah, I be lost ! Another question, does the timer in visual basic only go up to 60 seconds ? Anyway, I'll be waiting for the answers ?
Thanks Much
snagg
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2049125
If you have the Immediate window open, you should see a printout each time a file is saved. The Immediate window is located in the View menu.

The max interval for the timer is 65535.  If you need longer intervals, set the timer to 60000 (1 minute) and increment another variable (minutes) each time the timer event is raised.  When minutes = the number of minutes desired, then save the new image.
0
 

Author Comment

by:snagg
ID: 2049904
Erick37, Sorry to keep you waiting. I kind of played around and got my original code to work. It seemed to have served my purpose better. You have really nice code yourself so I will keep it for a possible later study. Thank You for for your prompt replies earlier !
Later Then
snagg
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6866879
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

715 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