Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,945 questions

51,887 answers

573 users

How to use private variable in class with VB.NET

2 Answers

0 votes
Imports System

Class Example
    Private n As Integer

    Public Sub New()
        n = 0
    End Sub

    Public Function f() As Integer
        Return n + 100
    End Function
End Class

Public Class Test
    Public Shared Sub Main()
        Dim o As Example = New Example()

        Console.WriteLine(o.f())
    End Sub
End Class
  
  
  
' Run:
'
' 100

 



answered Mar 28, 2019 by avibootz
0 votes
Imports System
 
Class Example
   Private s As String

    Public Sub New(ByVal _s As String)
        MyClass.s = _s

        Console.WriteLine(MyClass.s)
        Console.WriteLine(s)
        Console.WriteLine(_s)
    End Sub
End Class
 
Public Class Test
    Public Shared Sub Main()
        Dim o As Example = New Example("VB.NET")
    End Sub
End Class
   
   
   
' Run:
'
' VB.NET
' VB.NET
' VB.NET

 



answered Mar 28, 2019 by avibootz

Related questions

1 answer 212 views
1 answer 133 views
1 answer 144 views
...