CFanatic

Go Back   CFanatic > Programming > C++ Programming > Managed C++


  #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 Advance C 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 12:25 AM

 

Follow CFanatic on Twitter
CFanatic Search
Custom Search

Advertisement

Go4Expert's Job Board
Powered by

Go4Expert Newsletter
Enter your Name and Email Address below and Click Subscribe.

Subscriber Counter

Not planning to subscribe yet, browse Go4Expert's Newsletter Archive

All times are GMT -5. The time now is 03:23 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Looking for work in C, C++, C#? Sign up at Elance and search over 30,000 Freelancing jobs today.