473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Last four digits need to display in VB 6

2
Hi,
I would like to enter a number whose minimum and maximum length is 6 and 13.The number should be diaplayed as in the form of XXXX1234 i.e only last four digits should be diaplayed and the remaining should be diaplayed as X.
Can you send me the code.

For example if I enter 1234567 it should display as XXX4567
if I enter 89345684 it should display as XXXX5684


Note: The number I enter is having minmum length of 6 and maximum of 13.
Dec 31 '07 #1
7 7905
debasisdas
8,127 Expert 4TB
1.find out the length of the string.(ensure that is in the range of 6 and 13)
2.use right(string,4) to findout last 4 characters
3.filll the remaining with "X" from left side.
Dec 31 '07 #2
yaad
3
As you have already said you want to check of 6 digit to 13 so this code does not check that but checks to show XXX

Expand|Select|Wrap|Line Numbers
  1. A = Text1.Text
  2. LENA = Len(A)
  3. C = Right(A, 4)
  4. For I = 1 To LENA - 4
  5.   D = D & "x"
  6. Next
  7. E = D & C
  8. Label1.Caption = E
  9.  
Dec 31 '07 #3
Ali Rizwan
925 512MB
Hello,

Use this code

Expand|Select|Wrap|Line Numbers
  1. Text2.Text = Right (Text1.Text,4)
Have a nice day.

>> ALI <<
Dec 31 '07 #4
debasisdas
8,127 Expert 4TB
Hello,

Use this code

Expand|Select|Wrap|Line Numbers
  1. Text2.Text = Right (Text1.Text,4)
Have a nice day.

>> ALI <<
then what about the remaining characters ?

Who will convert that ?
Dec 31 '07 #5
Ali Rizwan
925 512MB
then what about the remaining characters ?

Who will convert that ?
I am really very sorry about that. I forgot about that.

This is the right code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3. For i = 1 To Len(Text1) - 4
  4.   Text2 = Text2 & "X"
  5. Next
  6.  
  7. Text2 = Text2 & Right(Text1, 4)
  8.  
  9. End Sub
Regards

>> ALI <<
Dec 31 '07 #6
CyberSoftHari
487 Expert 256MB
Simplifying ali’s code.

Expand|Select|Wrap|Line Numbers
  1. 'Will return string length of text1 -4 characters “X” to Text2
  2. Text2 = String(Len(Text1) - 4, "X")
  3. 'Add last 4 characters with Text2
  4. Text2 = Text2 & Right(Text1, 4)
Note: As site rule should not post code without explanation.
Dec 31 '07 #7
Killer42
8,435 Expert 8TB
Well, if it's about simplifying (or at least shortening) the code, how about...

Expand|Select|Wrap|Line Numbers
  1. ' Copy string from Text1 to Text2 with all but last 4 characters masked
  2. Text2 = String(Len(Text1) - 4, "X") & Right(Text1, 4)
Jan 1 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: middletree | last post by:
http://www.middletree.net/debug/DisplaySortableTickets.html Doing an Intranet-based app in ASP. I put the view source version (that is, no ASP code) out on my personal site at the above URL to...
1
by: Mr Newbie | last post by:
Does anyone know of a GOOD but FREE package which will parse my web logs and display standard information about hits, top visitors, referrers etc etc. Cheers -- Best Regards The Inimitable...
14
by: RonHouston | last post by:
Hi, I was wondering if someone could help me on this one. Is there anyway to format a string/integer etc so that it always outputs a 4 digits number? thank you. Ron.
2
by: dhutton | last post by:
How would one go about grabbing just the last 5 digits of a 16 digit number - then prefixing the last 5 numbers with 99800 so if the number is 8351101100000029 I need my SQL (Microsoft) to grab...
7
by: imtmub | last post by:
I have 3 table for Purchase Order from ERP Database Tables: POD=Purchase order Details(this table has Require Qty field) POR=Purchase Order Receive (This table has RequireQty and ReceiptQty...
2
by: mbewers1 | last post by:
Hi there I need to return the last 9 characters from a string, no matter what characters there are before it. Tried this: string id =...
9
by: andersond | last post by:
I am haviing a problem getting fields from a datatable to display if they contain digits, like 5.00 or $25.00. My php page will display any other variables without any problems. How can I get these...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.