RE: Moving the Cursor
- Posted by rudy toews <rltoews at ilos.net> Aug 10, 2002
- 730 views
Jon Snyder wrote: > > I'm trying to create an input field for a phone number that will > automatically add the dashes while the number is being input. The > problem is, is that after calling setText() the cursor is put at the > begining of the edit box so the number is entered backwards. Is there a > > way to move the cursor to the end of the edit box? > > Here is the code i have so far... > > > function removeDashes( sequence line) > sequence new_line > new_line = {} > for i = 1 to length( line) do > if line[i] != '-' then > new_line &= line[i] > end if > end for > return new_line > end function > function addDashes( sequence text) > integer length_text > length_text = length( text) > > if length_text > 3 then > text = text[1..3] & '-' & text[4..length_text] > end if > if length_text > 8 then > text = text[1..7] & '-' & text[8..length_text+1] > end if > > return text > end function > > boolean changing > changing = FALSE > procedure change_edit() > > if not changing then > changing = TRUE > setText( NUMBER_EDIT, addDashes( removeDashes( getText( NUMBER_EDIT) ) > > )) > changing = FALSE > end if > end procedure > onChange[ NUMBER_EDIT] = routine_id( "change_edit") > > hi Jon, still learning the windows programming myself. sorry i have no code to show you. but how about.. an edit box for each part of the phone number, placed beside one another making it look like one box. as each part of the phone number is keyed then the appropriate box is used by the code. an edit box could be the hyphen all by itself in between the other parts of the phone number. would work if area code is entered. if 3 numbers are keyed then they are assigned to the first box then the remainder is assigned to the box after the hyphen. later rudy toews lotterywars