Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to mask a string

Hello,
For a credit card need to throw a message box   masking the card number and only showing the last 4 digits.

Any Suggestion?
Cheers
Avatar of Russ Suter
Russ Suter

I've solved this problem a couple of ways in the past. One approach would be to create a class and override the ToString() method to return only the last 4 digits.

You may also need extra logic to test whether or not the number is a valid credit card number. Those rules vary depending on card brand but can be found with a little Googling.

Another approach if you don't really care about first verifying that what you're about to mask is actually a credit card number is to create an extension method that does the masking for you. This might not be an option for you since your question is tagged as both Visual Basic Classic and Visual Basic.NET. What platform are you actually using?
Avatar of RIAS

ASKER

Hi,
I am using vb.net 2005 windows version.I have found a solution for valid card number,just need to masking the number and pop up last 4 digits
Cheers
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Cheers!!