我试图让这个函数返回一个被屏蔽的数字。假设我有号码 123456789。如果我给它一个未屏蔽的值 4,我试图让它返回 *6789,或者如果我给它一个未屏蔽的值 3,则返回 *789。目前它显示数字中的位数,这就是我试图隐藏的。我一直在玩弄这个,但我不能让它做我想做的事。
Public Function GetMaskedNumber(ByVal sNumber As String, ByVal iUnmaskedLength As Integer, ByVal sMaskChar As String) As String
sMaskChar = Trim(sMaskChar)
If iUnmaskedLength > 0 AndAlso Len(sMaskChar) > 0 Then
GetMaskedNumber = New String(sMaskChar(0), iUnmaskedLength)
If iUnmaskedLength < Len(sNumber) Then
Mid(GetMaskedNumber, (Len(sNumber) - iUnmaskedLength), iUnmaskedLength + 1) = Right(sNumber, iUnmaskedLength)
Else
GetMaskedNumber = sNumber
End If
Else
GetMaskedNumber = sNumber
End If
End Function