Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Why Doesnt This Work Again?

Why Doesnt This Work Again?

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ryan B
    wrote on last edited by
    #1

    This doesnt work the way I want it to. Whats happening. :((

    Public Sub DoSomeWork()
    'This is Pseudo-Code
    ChangeImageBackColor(RED)
    DoTimeConsumingWork()
    ChangeImageBackColor(GREEN)
    End Sub

    For Some reason, I never see the Image change its Color? I forget why this doesnt work. Cheers Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

    C 1 Reply Last reply
    0
    • R Ryan B

      This doesnt work the way I want it to. Whats happening. :((

      Public Sub DoSomeWork()
      'This is Pseudo-Code
      ChangeImageBackColor(RED)
      DoTimeConsumingWork()
      ChangeImageBackColor(GREEN)
      End Sub

      For Some reason, I never see the Image change its Color? I forget why this doesnt work. Cheers Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

      C Offline
      C Offline
      Colin Leitner
      wrote on last edited by
      #2

      The good old DoEvents

      Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   DoEvents   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

      or in VB.NET

      Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   System.Windows.Forms.Application.DoEvents()   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

      R J 2 Replies Last reply
      0
      • C Colin Leitner

        The good old DoEvents

        Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   DoEvents   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

        or in VB.NET

        Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   System.Windows.Forms.Application.DoEvents()   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

        R Offline
        R Offline
        Ryan B
        wrote on last edited by
        #3

        Okay, I still dont get the results I want. The DoTimeConsumingWork() function is in a DLL I programmed in C++. I am using the ImageCOlor() as a busy indicator. Using Doevents as you have showed me does not work the way I need it to, which is "Show me when you start the function" - "Show me when you finish the function" Also I should note that this is VBA code Im writing in an excel spreadsheet. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

        C 1 Reply Last reply
        0
        • R Ryan B

          Okay, I still dont get the results I want. The DoTimeConsumingWork() function is in a DLL I programmed in C++. I am using the ImageCOlor() as a busy indicator. Using Doevents as you have showed me does not work the way I need it to, which is "Show me when you start the function" - "Show me when you finish the function" Also I should note that this is VBA code Im writing in an excel spreadsheet. Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.

          C Offline
          C Offline
          Colin Leitner
          wrote on last edited by
          #4

          This is a cheap example for Excel VBA but even works without DoEvents. Strange... Sub Process() Me.Cells(1, 1).Interior.Color = vbRed DoSomeWork Me.Cells(1, 1).Interior.Color = vbGreen End Sub Sub DoSomeWork() Dim s As String, n As Long For n = 0 To 13000 s = s + " " Next End Sub Got no idea then. Sorry!

          1 Reply Last reply
          0
          • C Colin Leitner

            The good old DoEvents

            Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   DoEvents   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

            or in VB.NET

            Public Sub DoSomeWork()   'This is also Pseudo-Code   ChangeImageBackColor(RED)   System.Windows.Forms.Application.DoEvents()   DoTimeConsumingWork()   ChangeImageBackColor(GREEN) End Sub

            J Offline
            J Offline
            Jason McBurney
            wrote on last edited by
            #5

            Do Events is evil... In general I have found that it cause more race conditions than anything. Try: ImageObject.Refresh()

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups