Hey I have class and I was wondering if I can do an OnChange event with the class. Basically if someone tries closing the program without saving the object I went a warning to pop up. The OnChange event will switch a changed property in the class.
Thanks
7 1334
If you have your own custom class, add a private boolean to determine if anything about the class has changed.
Then all all the function/properties of the class that would change it, be sure to set that boolean to true and trigger that onchange event?
If you have your own custom class, add a private boolean to determine if anything about the class has changed.
Then all all the function/properties of the class that would change it, be sure to set that boolean to true and trigger that onchange event?
I am trying this to handle the onchange event but it comes up with an error
for Me.OnChange - Event OnChange not found. How do I add an onchange event? - Public Sub OnChange() Handles Me.OnChange
-
ProfileChanged = True
-
End Sub
And here is the entire Class code -
Public Class Profile
-
-
Private ProfileFileName As String
-
Private ProfileDescription As String
-
Private ProfileVersion As Integer
-
Private ProfileNumAutoReduction As Integer
-
Private ProfileNumberLines As Integer
-
Private ProfilePrinterName As String
-
Private ProfilePrintOrientation As String
-
Private ProfilePaperSize As Integer
-
Private ProfileColumnsPerPage As Integer
-
Private ProfileRowsPerPage As Integer
-
Private ProfileHorizontalDisplacement As Integer
-
Private ProfileVerticalDisplacement As Integer
-
Private ProfileHorizontalSeperation As Integer
-
Private ProfileVerticalSeperation As Integer
-
Private ProfileLines As New Collection
-
Private ProfileChanged As Boolean = False
-
-
-
Public Sub OnChange() Handles Me.OnChange
-
ProfileChanged = True
-
End Sub
-
Public Sub New()
-
'This sub sets the defaults of the default Profile.
-
Me.Description = "New Profile"
-
Me.Version = 2
-
Me.NumAutoReduction = 4
-
Me.NumberLines = 4
-
Me.PrintOrientation = 2
-
Me.PaperSize = 260
-
Me.ColumnsPerPage = 1
-
Me.RowsPerPage = 1
-
Me.HorizontalDisplacement = 0
-
Me.VerticalDisplacement = 0
-
Me.HorizontalSeperation = 0
-
Me.VerticalSeperation = 0
-
Me.Changed = False
-
-
Dim Line As Collection = New Collection
-
Dim Line2 As Collection = New Collection
-
Dim Line3 As Collection = New Collection
-
Dim Line4 As Collection = New Collection
-
Dim Reduction As Collection = New Collection
-
Dim Reduction2 As Collection = New Collection
-
Dim Reduction3 As Collection = New Collection
-
Dim Reduction4 As Collection = New Collection
-
Dim Reduction5 As Collection = New Collection
-
-
Dim i As Integer = 1
-
-
Reduction.Add("True", "Enabled")
-
Reduction.Add("24", "Size")
-
Reduction.Add("Arial", "Font")
-
Reduction.Add("False", "Bold")
-
Reduction.Add("False", "Caps")
-
Reduction.Add("False", "Italic")
-
Reduction.Add("610", "HorizontalDisplacement")
-
Reduction.Add("-50", "VerticalDisplacement")
-
Reduction.Add("3960", "Width")
-
Reduction2.Add("18", "Size")
-
Reduction2.Add("Arial", "Font")
-
Reduction2.Add("False", "Bold")
-
Reduction2.Add("False", "Caps")
-
Reduction2.Add("False", "Italic")
-
Reduction2.Add("610", "HorizontalDisplacement")
-
Reduction2.Add("300", "VerticalDisplacement")
-
Reduction2.Add("3960", "Width")
-
Reduction3.Add("16", "Size")
-
Reduction3.Add("Arial Narrow", "Font")
-
Reduction3.Add("False", "Bold")
-
Reduction3.Add("False", "Caps")
-
Reduction3.Add("False", "Italic")
-
Reduction3.Add("610", "HorizontalDisplacement")
-
Reduction3.Add("500", "VerticalDisplacement")
-
Reduction3.Add("3960", "Width")
-
Reduction4.Add("14", "Size")
-
Reduction4.Add("Arial Narrow", "Font")
-
Reduction4.Add("610", "HorizontalDisplacement")
-
Reduction4.Add("-50", "VerticalDisplacement")
-
Reduction4.Add("3960", "Width")
-
Reduction4.Add("False", "Bold")
-
Reduction4.Add("False", "Caps")
-
Reduction4.Add("False", "Italic")
-
Reduction5.Add("12", "Size")
-
Reduction5.Add("Arial Narrow", "Font")
-
Reduction5.Add("False", "Bold")
-
Reduction5.Add("False", "Caps")
-
Reduction5.Add("False", "Italic")
-
Reduction5.Add("610", "HorizontalDisplacement")
-
Reduction5.Add("-50", "VerticalDisplacement")
-
Reduction5.Add("3960", "Width")
-
-
Line.Add(Reduction, "Reduction1")
-
Line.Add(Reduction2, "Reduction2")
-
Line.Add(Reduction3, "Reduction3")
-
Line.Add(Reduction4, "Reduction4")
-
Line2.Add(Reduction2, "Reduction1")
-
Line2.Add(Reduction3, "Reduction2")
-
Line2.Add(Reduction4, "Reduction3")
-
Line2.Add(Reduction5, "Reduction4")
-
Line3.Add(Reduction3, "Reduction1")
-
Line3.Add(Reduction4, "Reduction2")
-
Line3.Add(Reduction5, "Reduction3")
-
Line3.Add(Reduction5, "Reduction4")
-
Line4.Add(Reduction4, "Reduction1")
-
Line4.Add(Reduction5, "Reduction2")
-
Line4.Add(Reduction5, "Reduction3")
-
Line4.Add(Reduction5, "Reduction4")
-
-
Me.Lines.Add(Line, "Line1")
-
Me.Lines.Add(Line2, "Line2")
-
Me.Lines.Add(Line3, "Line3")
-
Me.Lines.Add(Line4, "Line4")
-
-
End Sub
-
-
Property Description() As String
-
Get
-
Return ProfileDescription
-
End Get
-
Set(ByVal value As String)
-
ProfileDescription = value
-
End Set
-
End Property
-
-
Property FileName() As String
-
Get
-
Return ProfileFileName
-
End Get
-
Set(ByVal value As String)
-
ProfileFileName = value
-
End Set
-
End Property
-
-
Property Version() As Integer
-
Get
-
Return ProfileVersion
-
End Get
-
Set(ByVal value As Integer)
-
ProfileVersion = value
-
End Set
-
End Property
-
-
Property NumAutoReduction() As Integer
-
Get
-
Return ProfileNumAutoReduction
-
End Get
-
Set(ByVal value As Integer)
-
ProfileNumAutoReduction = value
-
End Set
-
End Property
-
-
Property PrinterName() As String
-
Get
-
Return ProfilePrinterName
-
End Get
-
Set(ByVal value As String)
-
ProfilePrinterName = value
-
End Set
-
End Property
-
-
Property PrintOrientation() As String
-
Get
-
Return ProfilePrintOrientation
-
End Get
-
Set(ByVal value As String)
-
ProfilePrintOrientation = value
-
End Set
-
End Property
-
-
Property PaperSize() As Integer
-
Get
-
Return ProfilePaperSize
-
End Get
-
Set(ByVal value As Integer)
-
ProfilePaperSize = value
-
End Set
-
End Property
-
-
Property ColumnsPerPage() As Integer
-
Get
-
Return ProfileColumnsPerPage
-
End Get
-
Set(ByVal value As Integer)
-
ProfileColumnsPerPage = value
-
End Set
-
End Property
-
-
Property RowsPerPage() As Integer
-
Get
-
Return ProfileRowsPerPage
-
End Get
-
Set(ByVal value As Integer)
-
ProfileRowsPerPage = value
-
End Set
-
End Property
-
-
Property HorizontalDisplacement() As Integer
-
Get
-
Return ProfileHorizontalDisplacement
-
End Get
-
Set(ByVal value As Integer)
-
ProfileHorizontalDisplacement = value
-
End Set
-
End Property
-
-
Property VerticalDisplacement() As Integer
-
Get
-
Return ProfileVerticalDisplacement
-
End Get
-
Set(ByVal value As Integer)
-
ProfileVerticalDisplacement = value
-
End Set
-
End Property
-
-
Property HorizontalSeperation() As Integer
-
Get
-
Return ProfileHorizontalSeperation
-
End Get
-
Set(ByVal value As Integer)
-
ProfileHorizontalSeperation = value
-
End Set
-
End Property
-
-
Property VerticalSeperation() As Integer
-
Get
-
Return ProfileVerticalSeperation
-
End Get
-
Set(ByVal value As Integer)
-
ProfileVerticalSeperation = value
-
End Set
-
End Property
-
-
Public Property Lines() As Collection
-
Get
-
Return ProfileLines
-
End Get
-
Set(ByVal value As Collection)
-
ProfileLines = value
-
End Set
-
End Property
-
-
Property NumberLines() As Integer
-
Get
-
Return ProfileNumberLines
-
End Get
-
Set(ByVal value As Integer)
-
ProfileNumberLines = value
-
End Set
-
End Property
-
-
Property Changed() As Boolean
-
Get
-
Return ProfileChanged
-
End Get
-
Set(ByVal value As Boolean)
-
ProfileChanged = value
-
End Set
-
End Property
-
-
End Class
-
I think I have got something confused here.
I no longer understand why you want an event.
If at every function/property of your class that changes something, you ensure the boolean to be true. Then when you save, set the boolean to false. Simply checking that the boolean is false before closing would tell you if something has been changed?
I think I have got something confused here.
I no longer understand why you want an event.
If at every function/property of your class that changes something, you ensure the boolean to be true. Then when you save, set the boolean to false. Simply checking that the boolean is false before closing would tell you if something has been changed?
The thing is I don't want to write in every place I change the class that the class has chenged. This is why I want an onchange event. I just don't know how or if you can add an onchange event to a class.
If you want an onchange event, you would have to have to create it.
Which would entail coding it into every palce the object was changed.
OR have a background thread running that constantly compares the object to another instance of itself.
It might also be possible to do some unsafe code and watch the memory address to see if it has changed (Or possibly with serialization..checking to see if the serializaed version is different)
This is where good solid design before creating your objects come in to play.
If you want an onchange event, you would have to have to create it.
Which would entail coding it into every palce the object was changed.
OR have a background thread running that constantly compares the object to another instance of itself.
It might also be possible to do some unsafe code and watch the memory address to see if it has changed (Or possibly with serialization..checking to see if the serializaed version is different)
This is where good solid design before creating your objects come in to play.
So I can't do an onChange event like say a text box has a TextChanged event?
Where everytime a textbox changes text an event is triggered but you don't have to code an event everywhere you change a textbox's text.
So I can't do an onChange event like say a text box has a TextChanged event?
Where everytime a textbox changes text an event is triggered but you don't have to code an event everywhere you change a textbox's text.
Not unless you make it yourself.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe Kelsey |
last post by:
When you use addEventListener (or addEvent in IE) to call an object
method, does it call it with the correct this parameter?
The ECMAScript reference has a lot to say about the caller using...
|
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not...
|
by: fig000 |
last post by:
Hi,
I want to use a select object in asp and have the user pick
something from this select and have javascript open a window fired by
an event. Once the new window is open it displays another...
|
by: news.onetel.net.uk |
last post by:
I and my friend Karl have spent literally all day trying to find out what is
causing my error but we are zapped of any further functionality :)
I have a form that adds news records. You select...
|
by: Abby Lee |
last post by:
I want to use the same function for a number of fields.
<input name="taxi1" type="text" id="taxi1" size="8" onChange="myFunction
(this,1)">
function myFunction(val, itm) {
}
What can I do...
|
by: Joakim Braun |
last post by:
Why doesn't the below code work?
I'm trying to create a global object and set an event handler to one of its
methods. The function is called, but the object's mTest property is
undefined.
...
|
by: tshad |
last post by:
I have a function:
function SalaryDisplay(me)
{
var salaryMinLabel = document.getElementById("SalaryMin");
salaryMinLabel.value = 200;
alert("after setting salaryMinLabel = " +...
|
by: George |
last post by:
I need help with the code listed below. See the line below the
comment-// *** This displays the error ***
I want to be able to have the event handler call the function based on
the reference...
|
by: David C |
last post by:
I am getting this error in the Databound event of a GridView and I am having
a difficult time debugging. I do not get the error on every record that I
edit in the GridView. The error is occurring...
|
by: CreativeMind |
last post by:
hi all,
my dropdownlist 'cboUnitTypes' is populating on the base of another
dropdownlist1, i have to apply a check on 'cboUnitTypes' like
if(cboUnitTypes.value==0)return false; now
problem is;...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |