| | |
Expert in Class Creation & Implementation Needed
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 1
Reputation:
Solved Threads: 0
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.
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
- class creation and object creation... (C#)
- Class Errors (C++)
- Programmer needed in bonny Scotland! (Web Development Job Offers)
- methods in graphics class are abstract? (Java)
- Playing with RMI in Tiger (Java)
- Object-Oriented Programming (C++)
- can ANYONE help? need to make a queue (C)
Other Threads in the VB.NET Forum
- Previous Thread: string comparison in VB.net
- Next Thread: Problems on making Crystal Report
| Thread Tools | Search this Thread |
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function generatetags html images input intel internet listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms winsock wpf wrapingcode xml year





