Adding New member to TextBox..

G

Guest

Hi EveryBody:

How can I add Sub or Function or property to be a member of TextBox ?

For example TextBox1.Text , text is a property in Textbox1 How Can I add the
following sub to be a member of textbox1:

Public Sub SaveHtml(ByVal stream As Stream)
If stream Is Nothing Then
Throw New ArgumentNullException("SaveHtml : Must specify a
non-null stream to which to save")
End If
Dim content As String = SaveHtml()
Dim writer As New StreamWriter(stream, Encoding.UTF8)
writer.Write(content)
writer.Flush()
End Sub 'SaveHtml

Any Help or redirection will be appreciated

regard's

Husam
 
P

pvdg42

Husam said:
Hi EveryBody:

How can I add Sub or Function or property to be a member of TextBox ?

For example TextBox1.Text , text is a property in Textbox1 How Can I add
the
following sub to be a member of textbox1:

Public Sub SaveHtml(ByVal stream As Stream)
If stream Is Nothing Then
Throw New ArgumentNullException("SaveHtml : Must specify a
non-null stream to which to save")
End If
Dim content As String = SaveHtml()
Dim writer As New StreamWriter(stream, Encoding.UTF8)
writer.Write(content)
writer.Flush()
End Sub 'SaveHtml

Any Help or redirection will be appreciated

regard's

Husam

What you're talking about is extending the .NET Framework TextBox class.
Something like this in a class module...

Public Class MyTextBox Inherits TextBoxthen add your new method.

Once you've got your new subclass defined, you should be able to call your
method for instances of your new class.

For details, search through your MSDN help for articles on "subclassing",
"extending classes", "inheritance", etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top