Results 1 to 8 of 8

Thread: Form Validation

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    In a textbox how do i test to see if it contains an '@' symbol '.com' and for a date to see if it has three '/' in it ??

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ..long winded but it will work..


    Private Sub Command1_Click()

    Dim myString As String
    Dim myLen As Integer
    Dim myAt As Boolean
    Dim mySlash As Integer
    Dim iCount As Integer

    myAt = False

    myString = Text1.Text
    myLen = Len(myString)


    For iCount = 1 To myLen
    If Left(myString, 1) = "@" Then
    myAt = True
    End If
    If Left(myString, 1) = "/" Then
    mySlash = mySlash + 1
    End If
    myString = Right(myString, (myLen - iCount))


    Next

    If mySlash > 1 Then MsgBox "Yes, 2 or more / are involved."
    If myAt = True Then MsgBox "Yes, there is an @ involved."

    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Like is the fastest known operator!
    Code:
    IF text1 like "*@*" then Msgbox "@ involved"
    IF text1 like "*.com*" then Msgbox ".com involved"
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sorry i forgot the /'s well Hesaidjoe knows how to use instr, but this one will count them to 3, not 2 or more
    Code:
    a=instr$(text1,"/")
    Do while a
     counter=counter+1
     a=instr$(a+1,text1,"/")
    loop
    if counter=3 then msgbox "text1 has three / in it"
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Thanks guys, just what i needed, i'll try the shorter method first !!!!!

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ?

    I could count to 3 but I couldn't see where there are
    3 {/} in a date expression..I assume looking for 3 was a typo

    2000/07/02
    therefore if it's > 1 the possibilities are it's correct.

    assuming of course that the text1 text isn't something
    like this
    I came home/work and found my beer@mydesk/table was missing.

    LOL

    PS
    I like the like (it works extremely well)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    LOL

    Sorry about that HeSaidJoe


    if counter=2 ...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ///

    kedaman

    not a problem.

    Have a good one...gone out to enjoy the day!
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width