Solved

How to mask a number by using vbscript

Posted on 2006-10-25
5
569 Views
Last Modified: 2012-08-14
Hi,
I am outputting an account number, but for security reasons I would like to mask
all of the numbers except the last 4 digits.
For example: 123456789      -->        *****6789 or
                    121212127878 -->  ********7878 and so on.
 
Any ideas as to how to do this?

Thanks!
....
<table cellspacing="0" cellpadding="4" border="0" width="1144">
<tr>
<td width="80" align="left" style="border: 1 solid #2979b5"><p align="center">
      <font face="Arial" size="2">&nbsp;Account No</font></p></td>  
<tr>
       <td width="49" style="border: 1 solid #2979b5"><font face="Arial" size="2">&nbsp;<%=rs("AccountNo")%></font></td>

</tr>
<%rs.MoveNext
                     next%>
                             
</table>

0
Comment
Question by:avi4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 300 total points
ID: 17803524
there are 2 options in your case:
either do it already in the query, or indeed in the code.

<%=rs("AccountNo")%>

would be

<%=  space( len(rs("AccountNo") ) -4, "*" ) & right(rs("AccountNo"),4) %>
0
 
LVL 13

Accepted Solution

by:
jmundsack earned 200 total points
ID: 17805502
NO POINTS FOR ME PLEASE!

Angel--I think the function you meant was "String()" not "Space()"...

Instead of
    <%=  space( len(rs("AccountNo") ) -4, "*" ) & right(rs("AccountNo"),4) %>

Use
    <%=  String( len(rs("AccountNo") ) -4, "*" ) & right(rs("AccountNo"),4) %>

:)
0
 

Author Comment

by:avi4
ID: 17805963

Thanks so very much for all your great help!

It works perfectly :))

0
 
LVL 13

Expert Comment

by:jmundsack
ID: 17805980
Sorry angelIII, I wasn't trying to tap your points.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17806654
but you where right. I actually checked for the function name, saw string, but wrong space ...
good job
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question