Results 1 to 2 of 2

Thread: put this into VB code!

  1. #1

    Thread Starter
    Junior Member russianvbabe's Avatar
    Join Date
    Sep 2000
    Posts
    20

    Exclamation

    On start
    if text > 12 characters then return error
    end if
    check first character
    if first character is . Then return error

    check character
    loop if next character exists

    Check character
    if # or ? Or / then error

    if . Then check next 3 characters
    if 4th exists then error

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Talking See if this helps you out...

    Code:
    Option Explicit
    
    Private Function IsError(asTextIn As String) As Boolean
        ' This function returns true if there is an error in asTextIn
        
        Dim Counter As Integer
        Dim TempChar As String
        
        ' Check to see that asTextIn is 12 characters
        ' or less and the first character is not a "."
        If Len(asTextIn) > 12 Or Left$(asTextIn, 1) = "." Then
            IsError = True
            Exit Function
        Else
            ' For each character in asTextIn
            For Counter = 1 To Len(asTextIn)
                TempChar = Mid$(asTextIn, Counter, 1)
                
                ' If the character is "#" or "?" or "/" then return an error
                If TempChar = "#" Or TempChar = "?" Or TempChar = "/" Then
                    IsError = True
                    Exit Function
                ' Or if the character is "." and there are more
                ' than 3 characters after it, return an error
                ElseIf TempChar = "." And (Len(asTextIn) > (Counter + 3)) Then
                    IsError = True
                    Exit Function
                End If
            Next ' Counter
        End If
    End Function
    [Edited by seaweed on 11-09-2000 at 08:44 PM]
    ~seaweed

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