Every time when i use :
form1.show()
I get Reference to a non-shared member requires an object reference.
It worked till now.I don't know what's the problem.
Also,it does not even show in "Startup form" dropdown menu.
Edit : Included whole code.
Private _cpuid As String
///Here is the generated constructor
Sub New()
' TODO: Complete member initialization
End Sub
Public ReadOnly Property cpuid As String
Get
Return _cpuid
End Get
End Property
Private _pc As PerformanceCounter
Private _currentvalue As Integer = 0
Public Sub New(ByVal cpuid As String)
InitializeComponent()
_cpuid = cpuid
_pc = New PerformanceCounter("Processes", "CPU Usage (%)", cpuid)
Me.ProgressBar1.Maximum = 100
Me.ProgressBar1.Minimum = 0
Me.Label1.Text = "CPU" & cpuid
End Sub
Public Sub callperformancecounter()
_currentvalue = CInt(_pc.NextValue())
Me.ProgressBar1.Value = _currentvalue
Me.label2.text = _currentvalue & " %"
End Sub
assuming a form named form1 in the proj you need to create an instance of it:
EDIT for new info...
You have overridden the constructor, then not used it. I would not do it that way, do the CPU setup stuff in the Form Load event (just move the code). Fix your Sub New to this:
the form load would be the rest of your code:
You dont need to pass the cpuid to the procedure if you pass it to New or set the Property (you dont really need both methods for what you have so far).
NOW, the way you want to show the form is: