DunBee 0 Newbie Poster

I have created a class that I believe should work. I just need to validate date. I chose to validate user name and user password. I created the class and 2-3 properties (not sure 1 will work at all), and I need to create at least 1 function. I created a function that I want to return a value...the password for a given user. I am not sure how to call the Class or implement my properties or method. Please look at this code an help me get an idea on how to implement, or if you see obvious problems that will cause it to error out then please let me know. I can't see the it, I have never written a class or method (function) before, just simple procedures.

Option Strict Off
Option Explicit On
Imports System.Windows.Forms
Namespace DataValidation 'the following code defines our namespace
Public Class DataEntry
End Class
End Namespace
Public Class DataEntry 'Our new class
'Define a local variable to store the property value
Private Const Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Private Enabled As Boolean
'define validation types
Private ValidUser As ValueType
Public Enum ValueType
TextIsAlpha = 0
TextIsNumeric = 1
End Enum
'Define property for our class
Public Property UserName() As String
Get
Return UserName
End Get
Set(ByVal Value As String)
UserName = Value
End Set
End Property
'Define property for our class
Public Property UserPassword() As String
Get
Return UserPassword
End Get
Set(ByVal Value As String)
UserPassword = Value
End Set

End Property
'Define validateUser funciton which confirms that the correct string for selected user have been entered
Public Function ValidateUser() As String
Return UserName
End Function
Public Function Password() As ValueType

If ValidUser = ValueType.TextIsAlpha Then
MsgBox("Please enter Numeric Password", MsgBoxStyle.Exclamation)
Else
MsgBox("You may update Data", , "Valid User")
End If

Select Case Password
Case "Ken Ray"
ValidUser = "1000"
Case "Phyllis"
ValidUser = "2000"
Case "Brigette"
ValidUser = "3000"
Case "Mandy"
ValidUser = "4000"
Case "Rhonda"
ValidUser = "5000"
Case "Dr. B"
ValidUser = "6000"
Case Else
MsgBox("Please enter valid password", , "Invalid password")
End Select

End Function

End Class


I wanted to actually validate alpha and numeric code, hence the constant at the top...but I can't move onto that if I can't even get this to work. Any advise would be helpful. I inted to use the method in the txtUserPassword.Text_changed event handler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.