Discussion:
tab order
(too old to reply)
steve
2004-02-19 08:21:30 UTC
Permalink
Hi all i am writing a program to validate shipping container numbers.
Basically it gets each letter and number, gives it a value, does a bit of
math and spits out an answer (kinda like basic cd key validation). I
currently have 7 text boxes (one for each character). Everything works but i
dont know how to do the following:

Have a single text box and have it be able to work out each character.
OR
Set it up so that when i press a key it will automatically move the the next
text box. At the moment i have to tab to each box.

I prefer to have seperate text boxes for this app but i would like to learn
both ways of doing it.

thanks
steve
John Lauwers
2004-02-19 09:28:09 UTC
Permalink
Steve,

When the lenght of the textbox is a certain lenght then shift the focus to
another textbox.

Greets John
Post by steve
Hi all i am writing a program to validate shipping container numbers.
Basically it gets each letter and number, gives it a value, does a bit of
math and spits out an answer (kinda like basic cd key validation). I
currently have 7 text boxes (one for each character). Everything works but i
Have a single text box and have it be able to work out each character.
OR
Set it up so that when i press a key it will automatically move the the next
text box. At the moment i have to tab to each box.
I prefer to have seperate text boxes for this app but i would like to learn
both ways of doing it.
thanks
steve
steve
2004-02-20 07:50:05 UTC
Permalink
sorry i am a little bit out of my depth. I was never a big programmer (more
just for fun) and i have not touched it for a while. could you through a
little code my way or a link please?

thanks for your help

steve
Post by John Lauwers
Steve,
When the lenght of the textbox is a certain lenght then shift the focus to
another textbox.
Greets John
Post by steve
Hi all i am writing a program to validate shipping container numbers.
Basically it gets each letter and number, gives it a value, does a bit of
math and spits out an answer (kinda like basic cd key validation). I
currently have 7 text boxes (one for each character). Everything works
but
Post by John Lauwers
i
Post by steve
Have a single text box and have it be able to work out each character.
OR
Set it up so that when i press a key it will automatically move the the
next
Post by steve
text box. At the moment i have to tab to each box.
I prefer to have seperate text boxes for this app but i would like to
learn
Post by steve
both ways of doing it.
thanks
steve
Steve Gdula
2004-02-19 17:36:50 UTC
Permalink
The single text box approach:

dim intLen as integer, strChar as string*1
dim intCtr as integer, dblCharValues() as double

intLen=len(txtBox.text) 'Get length of Container Number (7?)
'Make sure you validate the value of the text box!

'Reserve memory to hold the char values
redim dblCharValues(1 to intLen)

for intCtr=1 to intLen
'Capture the current char
strChar=mid(txtBox.text,intCtr,1)

'Call a function of your design to assign
'the value to the current char
dblCharValues(intCtr)=AssignValue(strChar)

next intCtr

'Do what ever you need with your array of values.

--Another Steve.
Post by steve
Hi all i am writing a program to validate shipping container numbers.
Basically it gets each letter and number, gives it a value, does a bit of
math and spits out an answer (kinda like basic cd key validation). I
currently have 7 text boxes (one for each character). Everything works but i
Have a single text box and have it be able to work out each character.
OR
Set it up so that when i press a key it will automatically move the the next
text box. At the moment i have to tab to each box.
I prefer to have seperate text boxes for this app but i would like to learn
both ways of doing it.
thanks
steve
steve
2004-02-20 07:57:55 UTC
Permalink
thanks for your help. as i replied to another person who replied to my post
i am a little out of my depth and have been out of it for a while. I mainly
program for fun (and occasionally for work). Sorry if i seem like a pain,
just trying to get back into some coding (have fogotton way to much)
refer below
Post by Steve Gdula
dim intLen as integer, strChar as string*1
' the *1 refers to first character? if so then i would change to *2 for
second and so on?
Post by Steve Gdula
dim intCtr as integer, dblCharValues() as double
intLen=len(txtBox.text) 'Get length of Container Number (7?)
' yes 7
Post by Steve Gdula
'Make sure you validate the value of the text box!
'Reserve memory to hold the char values
redim dblCharValues(1 to intLen)
'does this save all or just the first character to memory? I am guessing the
first due to the 1 being present
Post by Steve Gdula
for intCtr=1 to intLen
'Capture the current char
strChar=mid(txtBox.text,intCtr,1)
'Call a function of your design to assign
'the value to the current char
dblCharValues(intCtr)=AssignValue(strChar)
' AssignChar is substituted for a number?
Post by Steve Gdula
next intCtr
'Do what ever you need with your array of values.
--Another Steve.
Post by steve
Hi all i am writing a program to validate shipping container numbers.
Basically it gets each letter and number, gives it a value, does a bit of
math and spits out an answer (kinda like basic cd key validation). I
currently have 7 text boxes (one for each character). Everything works but i
Have a single text box and have it be able to work out each character.
OR
Set it up so that when i press a key it will automatically move the the next
text box. At the moment i have to tab to each box.
I prefer to have seperate text boxes for this app but i would like to learn
both ways of doing it.
thanks
steve
Steve Gdula
2004-02-20 16:46:33 UTC
Permalink
Post by steve
' the *1 refers to first character? if so then i would change to *2 for
second and so on?
No, let me explain this:
Dim strValue as string*1 '*1 reserves mem to store 1 character in this variable
Dim strValue2 as string*3 '*3 reserves mem to store up to 3 chars in this variable
( I am only limiting the number of chars this string can hold )
Dim strValue as string 'Dimensioned this way, this variable can hold vast
'numbers of characters
Post by steve
Post by Steve Gdula
intLen=len(txtBox.text) 'Get length of Container Number (7?)
' yes 7
( The above approach will work for any length of 'Container Num' but if you
have a fixed length you can do that too - best advised to be flexible )
Post by steve
Post by Steve Gdula
'Reserve memory to hold the char values
redim dblCharValues(1 to intLen)
'does this save all or just the first character to memory? I am guessing the
first due to the 1 being present
' The above saves nothing to memory. It merely sets aside space in memory for
' a number of values that you will assign to each char ( 1 to 7 in your case)
Post by steve
Post by Steve Gdula
for intCtr=1 to intLen
'Capture the current char
strChar=mid(txtBox.text,intCtr,1)
'Call a function of your design to assign
'the value to the current char
dblCharValues(intCtr)=AssignValue(strChar)
' AssignChar is substituted for a number?
'The variables 'dblCharValues(1 thru 7) are assigned a number by
'a function called 'AssignValue'. 'AssignValue' is a function
'or possibly a number of lines of code directly in this for-next
'loop that assigns the value you have pre-determined to match the
'current char you have extracted.
Post by steve
Post by Steve Gdula
next intCtr
'Do what ever you need with your array of values.
--Another Steve.
Quicky explanation of 'Mid' function:
mid("ABC123",1,1) yields--> "A" mid("ABC123",2,1) yields--> "B"
mid("ABC123",5,1)yields--> "2" mid("ABC123",2,3) yields --> "BC1"

I have made everything as clear as possible. If you still do not
get the syntax or approach then it may be time to get an introductory
VB language book.

Good Luck,

Steve.
steve
2004-02-20 23:08:09 UTC
Permalink
thanks for your help. I have got a vb book here so i will get reading on
that as well

THANKS!!
Post by Steve Gdula
Post by steve
' the *1 refers to first character? if so then i would change to *2 for
second and so on?
Dim strValue as string*1 '*1 reserves mem to store 1 character in this variable
Dim strValue2 as string*3 '*3 reserves mem to store up to 3 chars in this variable
( I am only limiting the number of chars this string can hold )
Dim strValue as string 'Dimensioned this way, this variable can hold vast
'numbers of characters
Post by steve
Post by Steve Gdula
intLen=len(txtBox.text) 'Get length of Container Number (7?)
' yes 7
( The above approach will work for any length of 'Container Num' but if you
have a fixed length you can do that too - best advised to be flexible )
Post by steve
Post by Steve Gdula
'Reserve memory to hold the char values
redim dblCharValues(1 to intLen)
'does this save all or just the first character to memory? I am guessing the
first due to the 1 being present
' The above saves nothing to memory. It merely sets aside space in memory for
' a number of values that you will assign to each char ( 1 to 7 in your case)
Post by steve
Post by Steve Gdula
for intCtr=1 to intLen
'Capture the current char
strChar=mid(txtBox.text,intCtr,1)
'Call a function of your design to assign
'the value to the current char
dblCharValues(intCtr)=AssignValue(strChar)
' AssignChar is substituted for a number?
'The variables 'dblCharValues(1 thru 7) are assigned a number by
'a function called 'AssignValue'. 'AssignValue' is a function
'or possibly a number of lines of code directly in this for-next
'loop that assigns the value you have pre-determined to match the
'current char you have extracted.
Post by steve
Post by Steve Gdula
next intCtr
'Do what ever you need with your array of values.
--Another Steve.
mid("ABC123",1,1) yields--> "A" mid("ABC123",2,1) yields--> "B"
mid("ABC123",5,1)yields--> "2" mid("ABC123",2,3) yields --> "BC1"
I have made everything as clear as possible. If you still do not
get the syntax or approach then it may be time to get an introductory
VB language book.
Good Luck,
Steve.
Loading...