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. Changing the label text property with code.

Changing the label text property with code.

Scheduled Pinned Locked Moved Visual Basic
8 Posts 4 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.
  • A Offline
    A Offline
    AlainStP
    wrote on last edited by
    #1

    Hi all I am very new at programming anf I would like to do a very basic function, to change the label.text thru some code. The following code does not work but it will give you the basic idea of what I want done

    For i = 1 To number
    Label(i).text = i
    Next
    

    The reason is that my label will change in function of the day of the month Thank and keep up the good work. asp

    D C 2 Replies Last reply
    0
    • A AlainStP

      Hi all I am very new at programming anf I would like to do a very basic function, to change the label.text thru some code. The following code does not work but it will give you the basic idea of what I want done

      For i = 1 To number
      Label(i).text = i
      Next
      

      The reason is that my label will change in function of the day of the month Thank and keep up the good work. asp

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It works. The problem is that your code is running on the UI thread and blocks it so the WM_PAINT messages that are tacking up in your apps message queue don't get processed. That means that your label control is not receiving the Paint messages until after your code is done and your app is idle. That's when the label gets repainted. Also, what's with the Label() array?? Is this VB6 you're using?? If so, stop now and get VB.NET Express. It's free and you won't be teaching yourself some very bad habits forced on your by VB6.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      A S 2 Replies Last reply
      0
      • D Dave Kreskowiak

        It works. The problem is that your code is running on the UI thread and blocks it so the WM_PAINT messages that are tacking up in your apps message queue don't get processed. That means that your label control is not receiving the Paint messages until after your code is done and your app is idle. That's when the label gets repainted. Also, what's with the Label() array?? Is this VB6 you're using?? If so, stop now and get VB.NET Express. It's free and you won't be teaching yourself some very bad habits forced on your by VB6.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        A Offline
        A Offline
        AlainStP
        wrote on last edited by
        #3

        Ok Thanks for your answer I found how to do it with ctrlDict("label" & i).text

        D 1 Reply Last reply
        0
        • A AlainStP

          Ok Thanks for your answer I found how to do it with ctrlDict("label" & i).text

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Yeah, but that's not the best way to do it.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          A 1 Reply Last reply
          0
          • D Dave Kreskowiak

            It works. The problem is that your code is running on the UI thread and blocks it so the WM_PAINT messages that are tacking up in your apps message queue don't get processed. That means that your label control is not receiving the Paint messages until after your code is done and your app is idle. That's when the label gets repainted. Also, what's with the Label() array?? Is this VB6 you're using?? If so, stop now and get VB.NET Express. It's free and you won't be teaching yourself some very bad habits forced on your by VB6.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            S Offline
            S Offline
            slam Iqbal
            wrote on last edited by
            #5

            Good reply. Get VB.NET.......

            1 Reply Last reply
            0
            • A AlainStP

              Hi all I am very new at programming anf I would like to do a very basic function, to change the label.text thru some code. The following code does not work but it will give you the basic idea of what I want done

              For i = 1 To number
              Label(i).text = i
              Next
              

              The reason is that my label will change in function of the day of the month Thank and keep up the good work. asp

              C Offline
              C Offline
              Clark Kent123
              wrote on last edited by
              #6

              Give this video series a try. I am sure this will help you understand Visual Basic better. Channel 9 MSDN: Visual Basic For Beginers Video Series[^] I hope this helps. :)

              1 Reply Last reply
              0
              • D Dave Kreskowiak

                Yeah, but that's not the best way to do it.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                A Offline
                A Offline
                AlainStP
                wrote on last edited by
                #7

                Thank you all for your help. I know it's probably not the best way to do it, by creating a dictionnary, but since my project is small, it does the job for now. When I get better at coding I will look at other ways to do it. PS I am using Visual Studio 2010 ultimate. I have another question but I will post another thread Again thanks

                D 1 Reply Last reply
                0
                • A AlainStP

                  Thank you all for your help. I know it's probably not the best way to do it, by creating a dictionnary, but since my project is small, it does the job for now. When I get better at coding I will look at other ways to do it. PS I am using Visual Studio 2010 ultimate. I have another question but I will post another thread Again thanks

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  AlainStP wrote:

                  I know it's probably not the best way to do it, by creating a dictionnary

                  Thats not a dictionary. It's an array. The two are very different in their functionality and if you start using the incorrct terminology when referring to thi \sstuff in forums, you'll end up confusing people.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  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