CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

How to Validate character pattern in string topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2010, 12:54 AM
Junior Member
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
nhicks is on a distinguished road
| More
How to Validate character pattern in string

Hi, I have this in VBA. Don't know much about C++, if this can be done with C++, help would be appreciated. thank you...nelson
Code:
Function ValidAddr(addr As String) As Boolean
    Dim BadAddrs(2)
    Dim pos As Long
    Dim i As Integer
    pos = 0
    i = 0

    BadAddrs(0) = "PO BOX"
    BadAddrs(1) = "P.O BOX"
    BadAddrs(2) = " P.O. BOX"
    
    For i = LBound(BadAddrs) To UBound(BadAddrs)
        If (pos = 0) Then
            pos = InStr(1, addr, BadAddrs(i))
        End If
    Next i
    
    If (pos <> 0) Then
        ValidAddr = False
    Else
        ValidAddr = True
    End If
End Function

Sub CheckAddr()
    Dim isAddrPOBox As Boolean
    isAddrPOBox = False
    
    isAddrPOBox = ValidAddr("P.O BOX Rt. 11 P.O there")
    MsgBox isAddrPOBox
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why data() appends a NULL character at the end of string? LarryChen C++ Programming 0 06-22-2010 10:46 PM
How to insert a string into string? Tran C Programming 3 05-21-2008 09:51 PM
Print Japaneese character on Linux terminal & debugging problem rajeshgalla C Programming 0 04-14-2008 03:01 AM
msdos character mode console programming- multiple windows HowardL Driver Development 0 08-05-2007 11:35 AM
string to double kimw C Programming 1 12-26-2006 01:25 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 02:55 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board