Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keeping what is typed hidden

Status
Not open for further replies.

THEMAN101

Programmer
Apr 29, 2003
44
US
is there a way for the user to type something and for it to be analyzed but not for it to be displayed on screen. I am using

input "%- ", text$

i want to be able to use text$ but not for the user to see what he is typing.

thanx
 
don't use input. use inkey$.


do
do
a$ = inkey$
loop until a$ <> &quot;&quot;
text% = text% + a%

loop
hope this helps. let me explain this.

when a$ = inkey$, this assigns a$ the next key the user types. it exits the loop, and adds the letter the user typed to the array.

but a much easier way is to put this before your code:

color, 0

this makes the font color black.

but you may want to have a flashing _ showing the person he can type, right? so try this.

x = 1 'the x coordinate of the _
y = 1 'the y coordinate of the _
t = 1 'whether the _ is on or off 1 is on 0 is off
do
do
if t = 1 then 'if t is 1...
locate x, y 'it prints the _ and turns t to 0.
print chr$(95) 'prints the _...
t = 0 'turn off t
else 'if t is 0...
color = 0 'turns the color to black
locate x, y 'prints a black _ to cover up the white _.
print chr$(95)
color = 15 'turns color back to white
t = 1 'turns t back to 1.
endif

a$ = inkey$ 'assigns a$ to the next key you press

loop until a$ <> &quot;&quot; 'waits until you press a key
if a$ = chr$(27) then: print text$: end 'if the user presses escape, print text and end the program.
if a$ = chr$(13) then: exit sub 'i dunno if this'll work... if you press enter then it'll exit the sub.
'if a$ = chr$(8) 'i doubt this will work. hypothetically
'texta = len(text$) 'if you press backspace, it'll delete the last letter,
'text$(texta) = text$(texta) - 1 'but i really doubt it'd work.
'you could probably do it with the mid$ command or right$ command... i might try this later.
'that's why the code is REMed. it won't work because text$ is a string not an integer.

b = asc(a$) 'turns b into the asc value of the key you press
if b > chr$(32) and b < chr$(127) and b <> chr$(32) then when you press delete or whatever...
a$ = &quot;&quot; 'turns a$ to nothing.
else
text$ = text$ + a$ 'this adds the letter you press to the array.

loop 'start again.

now, this is just basic. i thought of this off the top of my head. if you know the ascii value of backspace you can delete the last character. here's how you do it. to do this you need to find out how long text$ is then minus one from it. it will delete the last letter. oh, and if the user presses enter, it'll exit the sub. (assuming this is in a sub. and if the user presses space, it'll make a space. you should be able to find out how to restrict how long to make the input. good day.

geeze, that's pretty long. anyways, take what you want, leave the rest. good day!
 
instead of this...
do
do
a$ = inkey$
loop until a$ <> &quot;&quot;
text% = text% + a%
loop


I would use this...
TEXT$ = &quot;&quot;
DO
A$ = INKEY$
IF A$ <> &quot;&quot;
SELECT CASE A$
CASE CHR$(27) 'ESC
EXIT DO
CASE CHR$(8) 'BACKSPACE
IF LEN(TEXT$) > 0 THEN TEXT$ = LEFT$(TEXT$,LEN(TEXT$)-1)
CASE CHR$(13) 'ENTER
EXIT DO
CASE ELSE
TEXT$ = TEXT$ + A$
END SELECT
END IF
LOOP UNTIL A$ = CHR$(13)

PRINT TEXT$
[/B]

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
*You can also limit the size of input...

MaxChar = 8
...
CASE ELSE
If LEN(TEXT$) <= MaxChar THEN TEXT$ = TEXT$ + A$
...

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
you could, but why limit the size? you'd also be limiting the quality of the program. but it's interesting.
 
i guess... can't think of any other ways to improve the program. think the topic maker will actually read this?

did you make the banner with flash?
 
The length of strings are automatically set at 255 characters, but that can be changed using DIM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top