?
Solved

class definitions

Posted on 2006-11-08
14
Medium Priority
?
231 Views
Last Modified: 2010-04-23
Can someone tell me what is wrong with this and how it is defined. I need to identify those areas that are incorrect and indicate what I need to do to fix it.  It has to do something with basic class definitions, please help...

Public Class _MyClass
    Private MyName As String
    Private MyAddress As String
    Public MyCity As String

    Private Property GetName()
        Get
            Return MyName
        End Get
        Set(ByVal Value)
            Value = MyName
        End Set
    End Property

    Public Property MyAddress()
        Get
            Return MyAddress
        End Get
        Set(ByVal Value)
            MyAddress = Value
        End Set
    End Property

    Public ReadOnly Property GetCity()
        Get
            Return GetCity
        End Get
    End Property

    Public Function CheckZipCode() As Boolean
        If IsNumeric(MyZipCode) = False Then
            Return False
        Else
            Return True
        End If
    End Function

    Private Sub CapitalizeNames()
        MyName = MyName.ToUpper
    End Sub
End Class


0
Comment
Question by:fahVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
14 Comments
 
LVL 10

Assisted Solution

by:Kinger247
Kinger247 earned 100 total points
ID: 17900379
1. MyZipCode is not declared
2. CheckZipCode should be read only.
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17900412
In fact theres a whole lot wrong with it (disregard number 2 previously).
whats this for ?
0
 
LVL 29

Assisted Solution

by:Nightman
Nightman earned 100 total points
ID: 17900414
MyName and MyAddress are already defined, so you can't create a property get or set for them with the same name.
MyZipCode is not declared.


Public Class _MyClass
  Private _MyName As String
  Private _MyAddress As String
  Private _MyZipCode As String
  Public MyCity As String

  Private Property GetName()
    Get
      Return _MyName
    End Get
    Set(ByVal Value)
      Value = _MyName
    End Set
  End Property

  Public Property MyAddress()
    Get
      Return _MyAddress
    End Get
    Set(ByVal Value)
      _MyAddress = Value
    End Set
  End Property

  Public ReadOnly Property GetCity()
    Get
      Return GetCity
    End Get
  End Property

  Public Function CheckZipCode() As Boolean
    If IsNumeric(_MyZipCode) = False Then
      Return False
    Else
      Return True
    End If
  End Function

  Private Sub CapitalizeNames()
    _MyName = _MyName.ToUpper
  End Sub
End Class
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Accepted Solution

by:
newyuppie earned 800 total points
ID: 17900441
homework?
besides kinger's suggestions:
1) Public Class _MyClass is not a CLS compliant name for a Class. you should remove the underscore (_)
2) in the SET part of the properties, you should identify the data type for the value passed to it.

for example in your code says:
Public Property MyAddress()
        Get
            Return MyAddress
        End Get
        Set(ByVal Value)
            MyAddress = Value
        End Set
    End Property

on the Set part, it should be
Set(ByVal Value as String)
            MyAddress = Value
        End Set

same for every other property.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17900459
3) you should have Imports Microsoft.VisualBasic if you are going to use the IsNumeric function (on the CheckZipCode function)
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17900474
4)
on
Public ReadOnly Property GetCity()
        Get
            Return GetCity
        End Get
    End Property

it should read
Public ReadOnly Property GetCity()
        Get
            Return MyCity
        End Get
    End Property

because you cant return a property.
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17900490
This looks like an exam question to me ???????????????????????????????
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17900493
5) MyName = MyName.ToUpper
lacks the ending ()
0
 

Author Comment

by:fahVB
ID: 17900547
wow too many suggestions. It is an exam question though. How do I allocate points now? So many guru's....

0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17900602
I think you should give us 500 each ;)
and if you pass your exam, a beer.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17900633
10% to Kinger247
10% to Nightman
80% to newyuppie

IMHO - Kinger and I both shot from the hip - newyuppie gave some really good feedback.
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 17900662
But then I twigged what this was for !
0
 

Author Comment

by:fahVB
ID: 17900669
Thanks for the suggestions guys.
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17901197
thanks to you, and thanks nightman for your opinion, but anyway i think you two also had very good points there. cheers
NY
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question