Click here to Skip to main content
15,908,768 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionIE Browser control in windows form(vb.net) onBlur event Pin
gspowar26-Oct-06 21:20
gspowar26-Oct-06 21:20 
QuestionFormatting Virtual Memory Display Pin
db_cooper195026-Oct-06 18:44
db_cooper195026-Oct-06 18:44 
AnswerRe: Formatting Virtual Memory Display Pin
Dave Kreskowiak27-Oct-06 5:25
mveDave Kreskowiak27-Oct-06 5:25 
GeneralRe: Formatting Virtual Memory Display Pin
db_cooper195027-Oct-06 5:52
db_cooper195027-Oct-06 5:52 
GeneralRe: Formatting Virtual Memory Display Pin
Dave Kreskowiak27-Oct-06 5:58
mveDave Kreskowiak27-Oct-06 5:58 
GeneralRe: Formatting Virtual Memory Display Pin
db_cooper195027-Oct-06 6:15
db_cooper195027-Oct-06 6:15 
GeneralRe: Formatting Virtual Memory Display Pin
Dave Kreskowiak27-Oct-06 6:23
mveDave Kreskowiak27-Oct-06 6:23 
GeneralRe: Formatting Virtual Memory Display Pin
db_cooper195027-Oct-06 6:37
db_cooper195027-Oct-06 6:37 
Dave Kreskowiak wrote:
Oh! And using a "global" variable like this (mVirtualMemory) is really bad practice! You're violating rules of Encapsulation and making it harder to debug your code. There is no reason, that I can see, for having that variable declared in Class scope. It should have been done inside the Property code.



Dave,
Please take a look at the following and then let me know that it is "Bad Practice", when the variable is used elsewhere in the class...

Public Class SystemMemory

#Region "Variables..."

Private mPhysicalMemory As Long
Private mVirtualMemory As ULong
Private mCombinedMemory As Long
Private mAvailablePhysicalMemory As Long
Private mAvailableVirtualMemory As ULong
Private mAvailableCombinedMemory As Long
Private mInstance As SystemMemory

Private mPctPhysicalMemory As Integer
Private mPctVirtualMemory As Integer
Private mPctCombinedMemory As Integer


#End Region


#Region "Constructors and Destructors..."
Public Sub New()
mInstance = Me
End Sub
Protected Overrides Sub Finalize()
mInstance = Nothing
End Sub
#End Region


#Region "Main Body in KB's..."


Public ReadOnly Property PhysicalMemory() As Long
Get
mPhysicalMemory = My.Computer.Info.TotalPhysicalMemory
mPhysicalMemory =(mPhysicalMemory / 1024)
Return mPhysicalMemory
End Get
End Property

Public ReadOnly Property VirtualMemory() As ULong
Get
mVirtualMemory = My.Computer.Info.TotalVirtualMemory
mVirtualMemory = mVirtualMemory / 1024
Return mVirtualMemory
End Get
End Property

Public ReadOnly Property CombinedMemory() As Long
Get
mCombinedMemory = (mPhysicalMemory + mVirtualMemory)
Return mCombinedMemory
End Get
End Property

....

I did not list where it is used elsewhere, but it is not just used inside the property call as the other private variables are also used elsewhere. Is is incorrect to call and use them in that manner?



DB_Cooper1950

"Life is like a box of..."

GeneralRe: Formatting Virtual Memory Display Pin
Dave Kreskowiak27-Oct-06 7:20
mveDave Kreskowiak27-Oct-06 7:20 
GeneralRe: Formatting Virtual Memory Display Pin
db_cooper195027-Oct-06 7:36
db_cooper195027-Oct-06 7:36 
GeneralRe: Formatting Virtual Memory Display Pin
Dave Kreskowiak27-Oct-06 8:40
mveDave Kreskowiak27-Oct-06 8:40 
GeneralRe: Formatting Virtual Memory Display Pin
db_cooper195027-Oct-06 8:58
db_cooper195027-Oct-06 8:58 
QuestionShow Data in Hierarcal Structure in .net control with multiple textboxes associated with each node.. [modified] Pin
TC2826-Oct-06 18:35
TC2826-Oct-06 18:35 
AnswerRe: Show Data in Hierarcal Structure in .net control with multiple textboxes associated with each node.. Pin
Dave Sexton26-Oct-06 22:16
Dave Sexton26-Oct-06 22:16 
GeneralRe: Show Data in Hierarcal Structure in .net control with multiple textboxes associated with each node.. Pin
TC2827-Oct-06 3:10
TC2827-Oct-06 3:10 
AnswerMessage Removed Pin
27-Oct-06 4:33
Costica U27-Oct-06 4:33 
QuestionRe: Show Data in Hierarcal Structure in .net control with multiple textboxes associated with each node.. Pin
TC2827-Oct-06 18:03
TC2827-Oct-06 18:03 
QuestionHow to create setup for VB and crystal report appl [modified] Pin
Software_Guy_12326-Oct-06 18:33
Software_Guy_12326-Oct-06 18:33 
QuestionCircle Packing Pin
batusai_3rd26-Oct-06 17:52
batusai_3rd26-Oct-06 17:52 
AnswerRe: Circle Packing Pin
Dave Sexton26-Oct-06 22:38
Dave Sexton26-Oct-06 22:38 
Questionhelp combobox Pin
Evalee26-Oct-06 17:26
Evalee26-Oct-06 17:26 
AnswerRe: help combobox Pin
Dave Sexton26-Oct-06 22:41
Dave Sexton26-Oct-06 22:41 
GeneralRe: help combobox Pin
Evalee27-Oct-06 0:36
Evalee27-Oct-06 0:36 
AnswerRe: help combobox Pin
Janani Divya27-Oct-06 1:49
Janani Divya27-Oct-06 1:49 
AnswerRe: help combobox Pin
Kschuler27-Oct-06 10:04
Kschuler27-Oct-06 10:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.