Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

vb6
I have prbably a silly question but I recently wrote code to loop through 8
bitmaps and display them in an image box.the code is

Private Sub Image2_Click()
Dim index As Integer

Show Image2
For i = 0 To 8
'index = index + 1
Print i
'Show; Image2.Picture
'index = index + 1
'Image2.Visible = True
For a = 1 To 1000000
Image2 = Image1(i)
Next a
'index = index + 1
'index = index
Next i
End Sub
I made a matrix of 8 bitmaps on form and one empty image box.but for some
reason it only loops through 5 or 6 and then jumps to 8 .What am I doing
wrong.

Report this thread to moderator Post Follow-up to this message
Old Post
tomS
04-27-05 01:55 AM


Re: vb6
"tomS" <tomS@discussions.microsoft.com> wrote in message
news:27C95C72-CB79-486C-B964-569EBB683320@microsoft.com...
>I have prbably a silly question but I recently wrote code to loop through 8
> bitmaps and display them in an image box.the code is
>
> Private Sub Image2_Click()
> Dim index As Integer
>
> Show Image2
> For i = 0 To 8
> 'index = index + 1
> Print i
> 'Show; Image2.Picture
> 'index = index + 1
> 'Image2.Visible = True
> For a = 1 To 1000000

The For loop above.... are you doing this for some kind of time delay? If
so, note that your "1000000" will take different amounts of time depending
on the CPU/RAM/etc the end user has. Also, you're assigning that image
1000000 times... no flicker? It's probably happening too fast to flicker.

> Image2 = Image1(i)
> Next a
> 'index = index + 1
> 'index = index
> Next i
> End Sub

> I made a matrix of 8 bitmaps on form and one empty image box.but for some
> reason it only loops through 5 or 6 and then jumps to 8 .What am I doing
> wrong.

If you start a new Project, drop a timer on the form (Timer1), drop an array
of 8 image controls (Image1(0-7)), another Image control (Image2) and 2
command buttons, called cmdGo and cmdStop, you should be able to see
"another way" of doing what you're trying to do.
'=============
Option Explicit

Private Sub cmdGo_Click()
Timer1.Tag = "" 'clear the "Flag"
Timer1.Enabled = True
DoEvents
cmdGo.Enabled = False
cmdStop.Enabled = True
End Sub

Private Sub cmdStop_Click()
Timer1.Tag = "STOP" 'set the "Flag"
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 500 '1/2 sec between pics - change this at will
Timer1.Tag = "STOP"
cmdStop.Enabled = False
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
If Timer1.Tag <> "STOP" Then
MsgBox "Click Stop first!"
Cancel = True
End If
End If
End Sub

Private Sub Timer1_Timer()
Static iElement As Integer

If Timer1.Tag = "STOP" Then
Timer1.Enabled = False
cmdGo.Enabled = True
cmdStop.Enabled = False
Else
Debug.Print "Showing image #" & iElement
Image2.Picture = Image1(iElement).Picture
iElement = iElement + 1
If iElement > Image1.UBound Then
iElement = 0
End If
End If

End Sub
'=============


--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..



Report this thread to moderator Post Follow-up to this message
Old Post
Ken Halter
04-27-05 01:55 AM


Re: vb6

"Ken Halter" wrote:

> "tomS" <tomS@discussions.microsoft.com> wrote in message
> news:27C95C72-CB79-486C-B964-569EBB683320@microsoft.com... 
>
> The For loop above.... are you doing this for some kind of time delay? If
> so, note that your "1000000" will take different amounts of time depending
> on the CPU/RAM/etc the end user has. Also, you're assigning that image
> 1000000 times... no flicker? It's probably happening too fast to flicker.
> 
> 
>
> If you start a new Project, drop a timer on the form (Timer1), drop an arr
ay
> of 8 image controls (Image1(0-7)), another Image control (Image2) and 2
> command buttons, called cmdGo and cmdStop, you should be able to see
> "another way" of doing what you're trying to do.
> '=============
> Option Explicit
>
> Private Sub cmdGo_Click()
>    Timer1.Tag = "" 'clear the "Flag"
>    Timer1.Enabled = True
>    DoEvents
>    cmdGo.Enabled = False
>    cmdStop.Enabled = True
> End Sub
>
> Private Sub cmdStop_Click()
>    Timer1.Tag = "STOP" 'set the "Flag"
> End Sub
>
> Private Sub Form_Load()
>    Timer1.Enabled = False
>    Timer1.Interval = 500 '1/2 sec between pics - change this at will
>    Timer1.Tag = "STOP"
>    cmdStop.Enabled = False
> End Sub
>
> Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
>    If UnloadMode = vbFormControlMenu Then
>       If Timer1.Tag <> "STOP" Then
>          MsgBox "Click Stop first!"
>          Cancel = True
>       End If
>    End If
> End Sub
>
> Private Sub Timer1_Timer()
>    Static iElement As Integer
>
>    If Timer1.Tag = "STOP" Then
>       Timer1.Enabled = False
>       cmdGo.Enabled = True
>       cmdStop.Enabled = False
>    Else
>       Debug.Print "Showing image #" & iElement
>       Image2.Picture = Image1(iElement).Picture
>       iElement = iElement + 1
>       If iElement > Image1.UBound Then
>          iElement = 0
>       End If
>    End If
>
> End Sub
> '=============
>
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> Sign up now to help keep VB support alive - http://classicvb.org/petition
> Please keep all discussions in the groups..
>
>
> Thanks that works good. There is one more thing I m tring to do and thats to be ab
le to index each picture in the array once each time I click the image2 box,meaning 
click box once ,first pic,click again second pic etc.

Report this thread to moderator Post Follow-up to this message
Old Post
tomS
04-27-05 08:55 AM


Re: vb6
"tomS" <tomS@discussions.microsoft.com> wrote in message
news:50FB33A6-24EA-4AC5-96AE-CAF23641BA46@microsoft.com...
>
> Thanks that works good. There is one more thing I m tring to do and thats
> to be able to index each picture in the array
> once each time I click the image2 box,meaning click box once ,first
> pic,click again second pic etc.

Very similar code.

> Private Sub Image1_Click(Index As Integer) 'untested air code
>    Dim iElement As Integer
>    iElement = Index + 1
>    If iElement > Image1.UBound Then
>       iElement = 0
>    End If
>    Debug.Print "Showing image #" & iElement
>    Image2.Picture = Image1(iElement).Picture
> End If


--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..



Report this thread to moderator Post Follow-up to this message
Old Post
Ken Halter
04-27-05 08:55 PM


Re: vb6

"Ken Halter" wrote:

> "tomS" <tomS@discussions.microsoft.com> wrote in message
> news:50FB33A6-24EA-4AC5-96AE-CAF23641BA46@microsoft.com... 
>
> Very similar code.
> 
>
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> Sign up now to help keep VB support alive - http://classicvb.org/petition
> Please keep all discussions in the groups..
>
>
> I tryed code but doesn t work it only shows last pic in array

Report this thread to moderator Post Follow-up to this message
Old Post
tomS
04-28-05 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:30 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.