Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 February 28th, 2006, 05:04 PM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default find and replace numbers in a string -- wildcards

How can I find and replace an unknown series of numbers, of known length, inside a string?

For example, I have the string "lajdsfasd 1234123412341234 asdf lkj". I don't know the number, but I know how long it is (credit card number). How can replace that CC number with other text?

Replace and Instr functions don't take wildcards (#, *).

I'm working in Access 2000 VBA, and deleting credit card data from our database.

thanks,

Conrad
 
Old February 28th, 2006, 06:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would split the string, and use the like operator to see if one of the component is a valid credit card number, something like:

p = split(mystring, " ")
dim stringOut as string
for i = 0 to ubound(p)
if p(i) like "################" then
stringOunt = StringOut & "**** "
else
stringOut = stringOut & p(i) & " "
endif
next

Marco
 
Old March 1st, 2006, 07:41 AM
Friend of Wrox
 
Join Date: May 2003
Posts: 229
Thanks: 0
Thanked 0 Times in 0 Posts
Default

By using split function you can spilt the string with *,#
then you can use like operator in if condition

Charul Shukla
 
Old March 1st, 2006, 07:41 AM
Friend of Wrox
 
Join Date: May 2003
Posts: 229
Thanks: 0
Thanked 0 Times in 0 Posts
Default

By using split function you can spilt the string with *,# or any space
then you can use like operator in if condition

Charul Shukla





Similar Threads
Thread Thread Starter Forum Replies Last Post
Find&Replace DoctorWho ASP.NET 1.0 and 1.1 Professional 3 June 6th, 2007 09:40 AM
Find and replace? Stuart Stalker SQL Server 2000 8 October 13th, 2005 02:49 AM
How do I quickly find version numbers for A-M-P? ababb BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 January 11th, 2005 02:26 PM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM





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