Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get a shift+tab into the program?
#1
I am entering data in a form in QB, and I want to allow the user to use shift + tab to go back to the previous field if needed.

Will it work to run a routine where it takes the inkey$ and if it's not a letter, put it into a temp$ and then add the 2nd inkey$ to it?

or am i over-complicating this?

I can make the inputs tab through the available fields, but I would like to be able to reverse if needed.


I tried gettting a multi-key.bas program online, but the one I got has call absolute(0) line that renders "sub-program not defined" error, which I don't understand how to resolve.

I don't need to have alt or control options available, everything else is done using function keys and menus.

(note: I did modify some code I found under the topic limiting the input$ length, so if that is your code I used, I appreciate your insight - I forget who posted the particular solution idea.)


CLS
PRINT "EDIT CUSTOMER: "
LOCATE 3, 1: COLOR 7, 0
PRINT "FIRST NAME: "
LOCATE 5, 1: COLOR 7, 0
PRINT "LAST NAME: "
LOCATE 7, 1: COLOR 7, 0
PRINT "PHONE #: (***) ***-****"
LOCATE 9, 1: COLOR 7, 0
PRINT "ALT. PHONE #: (***) ***-****"

add.name:

MaxLength% = 15
MyString$ = ""
finished% = 0
cursor$ = " "
x% = 3
y% = 15
LOCATE x%, y%: PRINT ">"
WHILE NOT finished%
LOCATE x%, y% + 1: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence
CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.last.name

END SELECT
WEND

add.last.name:

MaxLength% = 15
MyString$ = ""
finished% = 0
cursor$ = " "
x% = 5
y% = 15
LOCATE x%, y%: PRINT ">"
WHILE NOT finished%
LOCATE x%, y% + 1: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.area1

END SELECT
WEND


add.area1:


MaxLength% = 3
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 7
y% = 16
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.pre1

END SELECT
WEND
add.pre1:

MaxLength% = 3
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 7
y% = 21
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.last4

END SELECT
WEND
add.last4:


MaxLength% = 4
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 7
y% = 25
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.area2

END SELECT
WEND

add.area2:

MaxLength% = 3
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 9
y% = 16
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.pre2

END SELECT
WEND
add.pre2:

MaxLength% = 3
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 9
y% = 21
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO add.alt.last4

END SELECT
WEND
add.alt.last4:

MaxLength% = 4
MyString$ = ""
finished% = 0
cursor$ = "_"
x% = 9
y% = 25
WHILE NOT finished%
LOCATE x%, y%: PRINT cursor$ ' Cursor :)
k$ = INKEY$
IF k$ <> "" THEN k% = ASC(k$) ELSE k% = 0
SELECT CASE k%
CASE 13: ' This one is ENTER key
finished% = -1 ' End!
CASE 9:
finished% = -1 'end of this sequence

CASE 8: ' This one is Backspace key
IF MyString$ <> "" THEN ' Only if there is something to delete
LOCATE x%, y%: PRINT " " ' delete cursor
y% = y% - 1
MyString$ = LEFT$(MyString$, LEN(MyString$) - 1)' We delete the last char
END IF
CASE IS >= 32: ' From Space to infinite (letters/numbers...)
IF LEN(MyString$) < MaxLength% THEN ' <- Key!!
LOCATE x%, y%: PRINT k$
y% = y% + 1
MyString$ = MyString$ + k$
END IF

IF LEN(MyString$) = MaxLength% THEN GOTO leaving

END SELECT
WEND

leaving:
LOCATE 13, 15
PRINT "this is the end"
SYSTEM
Reply


Messages In This Thread
how to get a shift+tab into the program? - by moosecode - 01-28-2003, 08:14 PM
agamemnus - by Agamemnus - 01-28-2003, 08:53 PM
KISS - by moosecode - 01-28-2003, 09:12 PM
The "Subprogram not defined" error... - by Glenn - 01-28-2003, 09:20 PM
See relsoft's answer... - by Glenn - 01-29-2003, 10:00 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)