944,092 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3556
  • VB.NET RSS
Dec 9th, 2004
0

Expert in Class Creation & Implementation Needed

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DunBee is offline Offline
1 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: string comparison in VB.net
Next Thread in VB.NET Forum Timeline: Problems on making Crystal Report





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC