| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|
|||||||
| Visual Basic .NET Microsoft Visual Basic .NET and related questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Create Custom Button using Class ?
Hello CG members,
I use this code to create the same Button in multiple Forms: Code:
Dim btnClick As New Button btnClick.Location = New Point(106, 150) btnClick.Size = New Size(75, 23) btnClick.BackColor = Color.Brown btnClick.ForeColor = Color.White btnClick.Text = "Ok" I don't want to add the same code to all Forms. So i want to use Class to do the same work. How to do that ? Best Regards, SB4 |
|
#2
|
||||
|
||||
|
Re: Create Custom Button using Class ?
Create a new class ( Project, Add Class )
Type this into that class : Code:
Public Class ClsButton
Inherits Button
Public Sub New()
' Dim btnClick As New Button
Me.Location = New Point(106, 150)
Me.Size = New Size(75, 23)
Me.BackColor = Color.Brown
Me.ForeColor = Color.White
Me.Text = "Ok"
End Sub
End Class
Have a look at the attachment
__________________
My Latest Articles : Changing Mouse Settings with VB.NET || Creating Your Own Encryption / Decryption Program Using VB.NET 2005 || Autorun Menu Creator in VB.NET || Creating Your Own Tetris Game With VB.NET Part 1 Find All My Articles : Here FAQs : .NET FrameWork FAQs || Visual Basic.NET FAQs || C# FAQs Be The Change That You Want To See In The World - Michael Scofield, Prison Break; Season 1 Episode 1 Read This Before You Post || Acceptable Use Policy
|
|
#3
|
|||
|
|||
|
Re: Create Custom Button using Class ?
thanks HanneSThEGreaT
I test your file but it seems don't work with me I'm using Visual Stdio 2008. I have question Why you type New after you define the sub Procedure ? the keyword Me refer to what ? Best Regards, SB4 |
|
#4
|
||||
|
||||
|
Re: Create Custom Button using Class ?
OK, in future you must please specify what version of VB you are using, as stated here :
http://www.codeguru.com/forum/showthread.php?t=403073 New, is used for the class' initialisation, where it is given default startup values. Me refers to the current class, in this case, clsButton
__________________
My Latest Articles : Changing Mouse Settings with VB.NET || Creating Your Own Encryption / Decryption Program Using VB.NET 2005 || Autorun Menu Creator in VB.NET || Creating Your Own Tetris Game With VB.NET Part 1 Find All My Articles : Here FAQs : .NET FrameWork FAQs || Visual Basic.NET FAQs || C# FAQs Be The Change That You Want To See In The World - Michael Scofield, Prison Break; Season 1 Episode 1 Read This Before You Post || Acceptable Use Policy
|
|
#5
|
|||
|
|||
|
Re: Create Custom Button using Class ?
Ok, i'm using Visual Basic.NET 2008 Pro / .NET Framework 3.5 SP1 How to modify the code to work
|
|
#6
|
||||
|
||||
|
Re: Create Custom Button using Class ?
I can't understand that this code is not presumably compatible with .NET 3.5. It is just a normal Class file, with code still compatible in all versions of .NET.
Post your program ( in .zip format ) here, as an attachment, so that we can have a closer look.
__________________
My Latest Articles : Changing Mouse Settings with VB.NET || Creating Your Own Encryption / Decryption Program Using VB.NET 2005 || Autorun Menu Creator in VB.NET || Creating Your Own Tetris Game With VB.NET Part 1 Find All My Articles : Here FAQs : .NET FrameWork FAQs || Visual Basic.NET FAQs || C# FAQs Be The Change That You Want To See In The World - Michael Scofield, Prison Break; Season 1 Episode 1 Read This Before You Post || Acceptable Use Policy
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|