I need to slip a simple method into the following class,
the method should display a message box, displaying the entered
information..
Public Class employee
'Declaration of variables
Private iName, iTitle As String
Private iAge, iYearsofService As Integer
Property Name() As String
'The Property value is retrieved
Get
Return iName
End Get
Set(ByVal Value As String)
iName = Value
End Set
End Property
Property Title() As String
Get
Return iTitle
End Get
Set(ByVal Value As String)
iTitle = Value
End Set
End Property
Property Age() As Integer
Get
Return iAge
End Get
Set(ByVal Value As Integer)
iAge = Value
End Set
End Property
Property Yearsofservice() As Integer
Get
Return iYearsofservice
End Get
Set(ByVal Value As Integer)
iYearsofservice = Value
End Set
End Property
' Constructor
Public Sub New(ByVal Name As String, ByVal Title As String, _
ByVal Age As Integer, ByVal Yearsofservice As Integer)
Me.iName = Name
Me.iTitle = Title
Me.iAge = Age
Me.iYearsofservice = Yearsofservice
End Sub
End Class
######################
i can't figure the syntax,
thanks
Portroe 4 1266
First I would suggest that you not include a MessageBox call in the method
code, rather create a method or a property that returns a string that is
formatted the way that you would like it displayed. Doing it that way you
can consume the class in a non-windows application, like ASP.NET, a Windows
service, etc.
In any case, you'll want to make sure that you have a reference set to
System.Windows.Forms.dll and then you can do something like:
Imports System.Windows.Forms
Public Class employee
'Declaration of variables
Private iName, iTitle As String
Private iAge, iYearsofService As Integer
Public Sub ShowInfo()
MessageBox.Show(iName & vbNewLine & iTitle & iAge.ToString() &
iYearsofService.ToString())
End Sub
Property Name() As String
....
End Class
Brian M. Reisman
MCAD, MCDBA, MCSD,
MCSE, MCT, OCA, NET+
My book on amazon: http://www.amazon.com/exec/obidos/tg...l/-/0782141617
"portroe" <bo*@sleigh.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl... I need to slip a simple method into the following class,
the method should display a message box, displaying the entered information..
Public Class employee 'Declaration of variables Private iName, iTitle As String Private iAge, iYearsofService As Integer
Property Name() As String 'The Property value is retrieved Get Return iName End Get Set(ByVal Value As String) iName = Value End Set End Property
Property Title() As String Get Return iTitle End Get Set(ByVal Value As String) iTitle = Value End Set End Property
Property Age() As Integer Get Return iAge End Get Set(ByVal Value As Integer) iAge = Value End Set End Property
Property Yearsofservice() As Integer Get Return iYearsofservice End Get Set(ByVal Value As Integer) iYearsofservice = Value End Set End Property
' Constructor Public Sub New(ByVal Name As String, ByVal Title As String, _ ByVal Age As Integer, ByVal Yearsofservice As Integer) Me.iName = Name Me.iTitle = Title Me.iAge = Age Me.iYearsofservice = Yearsofservice End Sub End Class
######################
i can't figure the syntax,
thanks
Portroe
I really dont think u are serious but . .
Public sub displayPerson( msg as String )
MessageBox.Show( msg ) ' Msg composed of whatever you want and maybe &
other private variables
End Sub
Regards - OHM
Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
"portroe" <bo*@sleigh.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl... I need to slip a simple method into the following class,
the method should display a message box, displaying the entered information..
Public Class employee 'Declaration of variables Private iName, iTitle As String Private iAge, iYearsofService As Integer
Property Name() As String 'The Property value is retrieved Get Return iName End Get Set(ByVal Value As String) iName = Value End Set End Property
Property Title() As String Get Return iTitle End Get Set(ByVal Value As String) iTitle = Value End Set End Property
Property Age() As Integer Get Return iAge End Get Set(ByVal Value As Integer) iAge = Value End Set End Property
Property Yearsofservice() As Integer Get Return iYearsofservice End Get Set(ByVal Value As Integer) iYearsofservice = Value End Set End Property
' Constructor Public Sub New(ByVal Name As String, ByVal Title As String, _ ByVal Age As Integer, ByVal Yearsofservice As Integer) Me.iName = Name Me.iTitle = Title Me.iAge = Age Me.iYearsofservice = Yearsofservice End Sub End Class
######################
i can't figure the syntax,
thanks
Portroe
Very good . . .
Regards - OHM
MCAD, MCDBA, MCSD, MVP, MORe, MVBA,MNPA
MCSE, MCT, OCA, NET+, NWA, BWO, OBE, MRDO,MBizTA
========================================
Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
"Brian M. Reisman" <br****@online.onlc.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... First I would suggest that you not include a MessageBox call in the method code, rather create a method or a property that returns a string that is formatted the way that you would like it displayed. Doing it that way you can consume the class in a non-windows application, like ASP.NET, a
Windows service, etc.
In any case, you'll want to make sure that you have a reference set to System.Windows.Forms.dll and then you can do something like:
Imports System.Windows.Forms
Public Class employee 'Declaration of variables Private iName, iTitle As String Private iAge, iYearsofService As Integer
Public Sub ShowInfo() MessageBox.Show(iName & vbNewLine & iTitle & iAge.ToString() & iYearsofService.ToString())
End Sub Property Name() As String ...
End Class
Brian M. Reisman MCAD, MCDBA, MCSD, MCSE, MCT, OCA, NET+ My book on amazon:
http://www.amazon.com/exec/obidos/tg...l/-/0782141617 "portroe" <bo*@sleigh.com> wrote in message news:u3**************@TK2MSFTNGP10.phx.gbl... I need to slip a simple method into the following class,
the method should display a message box, displaying the entered information..
Public Class employee 'Declaration of variables Private iName, iTitle As String Private iAge, iYearsofService As Integer
Property Name() As String 'The Property value is retrieved Get Return iName End Get Set(ByVal Value As String) iName = Value End Set End Property
Property Title() As String Get Return iTitle End Get Set(ByVal Value As String) iTitle = Value End Set End Property
Property Age() As Integer Get Return iAge End Get Set(ByVal Value As Integer) iAge = Value End Set End Property
Property Yearsofservice() As Integer Get Return iYearsofservice End Get Set(ByVal Value As Integer) iYearsofservice = Value End Set End Property
' Constructor Public Sub New(ByVal Name As String, ByVal Title As String, _ ByVal Age As Integer, ByVal Yearsofservice As Integer) Me.iName = Name Me.iTitle = Title Me.iAge = Age Me.iYearsofservice = Yearsofservice End Sub End Class
######################
i can't figure the syntax,
thanks
Portroe
Portroe,
As Brian suggested, I would recommend creating a method that returns a
string that is formatted.
..NET has defined a consistent name for this method, that name being the
overridable method ToString that is inherited from System.Object.
A variation of Brian's sample that overrides Object.ToString would be:
Public Class employee
'Declaration of variables
Private iName, iTitle As String
Private iAge, iYearsofService As Integer
Public Sub ShowInfo()
MessageBox.Show(me.ToString())
End Sub
Public Overrides Function ToString() As String
Return iName & vbNewLine & iTitle & _
iAge.ToString() & iYearsofService.ToString()
End Function
End Class
This allows an Employee object to be used with various other classes in the
framework that will call Object.ToString to get a displayable representation
of the object. (for example adding an Employee object itself to a ListBox,
the ListBox will call ToString to get the value to display in the ListBox.
Hope this helps
Jay
"portroe" <bo*@sleigh.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl... I need to slip a simple method into the following class,
the method should display a message box, displaying the entered information..
Public Class employee 'Declaration of variables Private iName, iTitle As String Private iAge, iYearsofService As Integer
Property Name() As String 'The Property value is retrieved Get Return iName End Get Set(ByVal Value As String) iName = Value End Set End Property
Property Title() As String Get Return iTitle End Get Set(ByVal Value As String) iTitle = Value End Set End Property
Property Age() As Integer Get Return iAge End Get Set(ByVal Value As Integer) iAge = Value End Set End Property
Property Yearsofservice() As Integer Get Return iYearsofservice End Get Set(ByVal Value As Integer) iYearsofservice = Value End Set End Property
' Constructor Public Sub New(ByVal Name As String, ByVal Title As String, _ ByVal Age As Integer, ByVal Yearsofservice As Integer) Me.iName = Name Me.iTitle = Title Me.iAge = Age Me.iYearsofservice = Yearsofservice End Sub End Class
######################
i can't figure the syntax,
thanks
Portroe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Rahardja |
last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at
work. He is a proponent of the Template Method pattern, i.e.:
class foo
{
public:
void bar() { do_bar(); }
protected:...
|
by: daniel.w.gelder |
last post by:
I wrote a template class that takes a function prototype and lets you
store and call a C-level function, like this:
inline string SampleFunction(int, bool) {..}
functor<string (int, bool)>...
|
by: kuvpatel |
last post by:
Hi
I want to refer a class called LogEvent, and use one of its methods called
WriteMessage without actually having to create an instance of Logevent.
I have tried using the word sealed with...
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS...
|
by: JohnR |
last post by:
From reading the documentation, this should be a relatively easy thing. I
have an arraylist of custom class instances which I want to search with
an"indexof" where I'm passing an instance if the...
|
by: ddtl |
last post by:
Hello everybody.
Consider the following code:
class A(object):
def met(self):
print 'A.met'
class B(A):
def met(self):
|
by: Alan T |
last post by:
I got a method in my ancestor form declared as Protected, this method has
empty body.
In my descendant form I declared as Protected also, then compile has no
problem but the name of the method has...
|
by: bryanbabula |
last post by:
I have a question about overriding i was wondering if anyone could
help me with, or even suggesting a better/different way. I have no
idea if this can even be done or not.
I was wondering if there...
|
by: Steve Richter |
last post by:
in a generic class, can I code the class so that I can call a static
method of the generic class T?
In the ConvertFrom method of the generic TypeConvert class I want to
write, I have a call to...
|
by: VK |
last post by:
<OT>I am finishing TransModal 0.1 so planning to move it from alpha to
beta stage.<OT>
Besides that I am planning to write an introductory to inheritance
schema currently used in Javascript...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |