I'm new in Vb.net and try to make a simple program. I need one variable to be used in all subs. How can i do that with this:

RTB As Richtextbox = CType(TabControl1.SelectedTab.Controls.Item(0), Richtextbox)

Search in google, you will definitly get information.

Search in google, you will definitly get information.

I use this,

Public RTB As Richtextbox = CType(TabControl1.SelectedTab.Controls.Item(0), Richtextbox)

Private Sub (Blah Blah) Handles Button1.Click
    If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
        RTB.Font = FontDialog1.Font
    End If
End Sub

And Get error: Object reference not set to an instance of an object.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.