Wrox Programmer Forums
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2005, 03:29 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default Text Field Validation


I am developing Institute management System and I am using VB 6 & MS Access. Now I when Register student or teacher there are some texts fields which are only contain Numbers (Phone No) and Email address. Now I want to enforce that in Phone No Text field user can’t write Text, and want to verify that the email address entered by user is valid in format as [email protected].

Any help would be appreciated.







Zaeem Sherazi
__________________
Zaeem Sherazi
 
Old May 27th, 2005, 12:36 PM
Authorized User
 
Join Date: Jul 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to chipset Send a message via MSN to chipset Send a message via Yahoo to chipset
Default

hi
lets assume tou have two textbox and a commandbutton
names txtEmailAddress, txtPhone and txtValidate respectively


i thin this few lines of code shold help

Code:
Option Explicit

Private Sub cmdValidate_Click()
    Dim sTemp As String
    sTemp = txtEmailAddress.Text
    If Not (CheckForAltSign(sTemp) And CkechDotSign(sTemp)) Then _
        MsgBox "Please check the email address properly", vbCritical, "Error"

End Sub
Private Function CkechDotSign(sTheString As String) As Boolean
    Const sExtenssions As String = ".com.uk.net" ' add more extenssions
    Dim i As Integer
    Dim sSigEx() As String
    sSigEx() = Split(sExtenssions, ".")
    For i = 1 To UBound(sSigEx)
        If sSigEx(i) = Right$(sTheString, Len(sSigEx(i))) Then CkechDotSign = True
    Next i
End Function

Private Function CheckForAltSign(TheString As String) As Boolean
    Dim i As Integer
    Dim iLenStr As Integer
    Dim iNumOfAlt As Integer
    iLenStr = Len(TheString)
    For i = 1 To iLenStr
        If Mid$(TheString, i, 1) = "@" Then iNumOfAlt = iNumOfAlt + 1
        If Mid$(TheString, i, 2) = "@." Then Exit Function
        If Left$(TheString, 1) = "@" Then Exit Function
    Next
    If iNumOfAlt = 1 Then CheckForAltSign = True
End Function

Private Sub txtPhone_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 48 To 57, 8
            'do nothing
        Case Else
            KeyAscii = 0
    End Select
End Sub
Arowolo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text(Sql Server Text Field) to Image(JPG) srinivas72 ADO.NET 2 February 13th, 2009 06:31 PM
Validation on a date field. OneQuestion ADO.NET 3 January 6th, 2008 01:30 AM
Field Array Validation in Javascript Asad Khan Apache Tomcat 1 September 4th, 2007 06:14 AM
Field Validation in an Editable Data Grid Shadane ASP.NET 1.0 and 1.1 Basics 3 October 2nd, 2006 09:02 AM
Field Validation Thurston Access 5 November 14th, 2005 12:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.