Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interrupting a running routine with a button push 1

Status
Not open for further replies.

JamesBBB

Technical User
Nov 2, 2005
74
GB
Hi All,

Ive got a bit of a problem here that has got me stumped.
Bascially I have a piece of code here that sets up a slideshow in a picture box and it runs beautifully, however I cant make it stop during the show, it has to run all the way through.
what I tried to do to stop the slideshow running, was to set up a Public Integer call intbreak and on starting the slideshow I set intbreak = 0

Then as the slide show is running, there is another button on the form that sets the public variable to 1, I then tried puttting in an "if Intbreak=1 statement", but it does not work and I get a "wend with no while" error, it seems that if I put an if statement in the middle it gets confused.

Anybody any ideas on how I can quit this routine on a button puch while its running.

Any help would be most gratfully recieved.

many thanks

James

The Code on the Slideshow Button:-

Code:
Dim X As Integer
Dim intbreak As Integer
intbreak = 0
Dim fs1
Set fs1 = CreateObject("Scripting.filesystemobject")
Dim ab As String
abloc = Sysdrive & ":" & Sysdir & Collection 'Public Variables to get basic path
Title = "Speed Settings" ' Set title.
Defvalue = "400"      ' Set default return value.
numx = InputBox(Msg, Title, Defvalue) ' Get user input.

Dim rst As New ADODB.Recordset
rst.Open "IssuesAlpha", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, adCmdTable
While Not rst.EOF
aax = rst![F1] ' Get record from table
ab = Len(aax) ' get length of string
ab1 = Left(aax, ab - 4) 'remove the extension of the filename
ab2 = abloc & "\coversthumb\" & ab1 & ".jpg" 'add .jpg to the filename   
 If fs1.FileExists(ab2) = True Then
 Image1.Picture = ab2 ' set the picture for the slideshow
 End If
rst.MoveNext  ' get the next filename
For X = 1 To numx ' delay to allow picture to stay on screen as set above
DoEvents
Next X

'If Intbreak = 1 Then  ' Tried this, but it did not work.
'Exit Sub
'End If

Wend
rst.Close
 
JamesBBB,
Move [tt]Dim intbreak As Integer[/tt] into the global declarations of your object (form)? This way other routines can see and change it.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
CautionMP

Fantastic, Worked a treat, never thought of doing that, I made public string in a module and thought that would have done it.

Many thanks

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top