Saving from components declared in function or sub

Joined
Jul 2, 2003
Messages
17
Location
Ouston, Newcastle Upon Tyne, England
does any one know how to save from components declared in functions or sub routine in my case its a richtext which is declared in the function and only know to that function and placed in to document manager which i got from divil.co.uk/net

heres the syntax i used to declare it


Private Sub newdoc()
Dim rtbText As New RichTextBox
rtbText.BorderStyle = BorderStyle.None
rtbText.ScrollBars = RichTextBoxScrollBars.Vertical
rtbText.WordWrap = True

rtbText.Multiline = True
rtbtext.ScrollBars = ScrollBars.Vertical

Dim doc As New Document(rtb, "New Document")
docMain.AddDocument(doc)


End Sub

i want to know how to save from that but it is only known locally to the sub newdoc()
i also would like to to know how to change the fonts and in the box but but i ill work that out once i find out how to access the richtext box from out side the sub

if anyone can help ill be chuffed
 
I would either rdeclare the rtbText as Public or have a Public object and assign rtbText to it once you have created it.

There probably is a better way but its 7:34am, I just got up so my brain is still asleep:)
 
You could declare it without an instance where all subs and functions can access it and then in the newdoc sub just create an instance from that variable, it will accessible to all subs and functions in the class.
 
Back
Top