1

Im using: Visual Studio 2013 (Visual Basic) >>NOT<< C# :)

So, I am making a program which is checking how much space you have on a harddrive, so, when there is less then 20% memory, I want the progressbar change its color to red, usually it is green, so I hope this is possible, thankyou so much.

  • possible duplicate of [How to change the color of progressbar in C# .NET 3.5?](http://stackoverflow.com/questions/778678/how-to-change-the-color-of-progressbar-in-c-sharp-net-3-5) – Ben N Apr 27 '15 at 16:26
  • 1
    Look into https://msdn.microsoft.com/en-us/library/aa335455%28v=vs.71%29.aspx ... – Trevor Apr 27 '15 at 16:28
  • 1
    @AlexanderFalkesund I'd agree that it's not a duplicate (due to it being the wrong language), however, anything that's possible in C# is usually translatable fairly easily into VB (and vice versa). Take a look at the [second answer](http://stackoverflow.com/a/9753302/791010) - looks good to me. – James Thorpe Apr 27 '15 at 16:29

1 Answers1

0

Import SendMessage:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
    End Function

And use this function:

SendMessage(ProgressBar1.Handle, 1040, 2, 0)

Color codes:

1: green
2: red
3: yellow
Eun
  • 4,146
  • 5
  • 30
  • 51
  • And where in the code should I put the color codes? –  Apr 28 '15 at 05:44
  • Third parameter is an integer, that sets the color, apparently only these three colors are available. – Eun Apr 28 '15 at 05:45