Main
   Home
   About
   DiscussionBoard
Files
   About
   Submit
   Search
Downloads
   Action
   QB64
Links
   Link to us
QB45.org
[ Back to QB45 | FAQ | Search a message | Reply to this message | Back to messages ]

gablea on 09/06/11 - 15:51:27

hi all

how do I repalce a given number of chrs in a string with *'s?

example
card :1234567890123456789
I want to display / print
card :12345678***********

any advice is welcome

John on 09/06/11 - 21:24:13

Use the function called "MID$".
The parameters are MID$(input string, start position, how many chars do you want to take).

Also you could have a try with "RIGHT$()"

Take a look at the QB Help!

Good luck!

Cyperium on 09/16/11 - 11:23:13

You would use MID$ like this (following your example):

position = 9
card$ = "1234567890123456789"
MID$(card$,position) = "***********"
PRINT card$

You don't need to specify the number of characters to replace. It will only replace to the length of the string (or to the length specified, if you specify a length, but no longer than the length of the string).

gablea on 09/17/11 - 11:17:25

That worked perfectly Thanks Cyperium :D

Cyperium on 10/24/11 - 14:44:28

You're welcome, admittedly John already showed you which function to use, but I felt that you might have been confused as to how you would use it. I don't have internet at home right now so I might be slow on responding.

Reply to this message
Name:
Message:
Please enter this number:
No HTML allowed. You may use BB-code in your posting.
Members
Login
Register
QB45 Members
Member List