[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

Defult value of an object

I am trying to set a default value for "sheet" below.  Meaning if it hasn't been set to anything yet then return 0 by default.  How do I do that?

private mSheet as long

Public Property Get Sheet() As Long
  Sheet = mSheet
End Property

Thanks,
axnst1
0
axnst2
Asked:
axnst2
  • 2
1 Solution
 
vb_elmarCommented:
You can arrange a Constant. When running the Program, Me.Sheet = 1
or any other Value you want.

Const mSheet = 1

Public Property Get Sheet() As Long
  Sheet = mSheet
End Property

Private Sub Form_Load()
Caption = Me.Sheet
End Sub
0
 
AzraSoundCommented:
That looks fine.  By default, long values have a value of 0, so mSheet should be 0 until you change it otherwise.
0
 
vb_elmarCommented:
Get is a read only property. Do you want to write to "Sheet" ?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now