Results 1 to 10 of 10

Thread: generic function containing a textbox

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2005
    Posts
    1,069

    Resolved generic function containing a textbox

    Hello

    I have got about 14 textboxes which use similar routines, the routines read and write to the textboxes the same way, the only difference is these routines is the name of the textbox.

    is it possible for me to create a generic routine which will manipulate the textboxes in the same way.

    e.g i have 5 textboxes,

    footext1, footext2, footext3, footext4 & footext5

    now the routine is say
    VB Code:
    1. footext1_change()
    2.  
    3.       uppervalue = 100
    4.        lowervalue = footext2.text
    5.        if ((footext1.text<uppervalue ) and (footext1.text>lowervalue)) then
    6.               error_flag=true
    7.        else
    8.                footext1 = 30
    9.                 error_flag = false
    10.        end if
    11.  
    12. end sub

    and for text2 it is

    VB Code:
    1. footext2_change()
    2.  
    3.       uppervalue = 100
    4. lowerrvalue = footext3.text
    5.        if ((footext2.text<uppervalue ) and (footext2.text>lowervalue)) then
    6.               error_flag=true
    7.        else
    8.                footext2 = 30
    9.                 error_flag = false
    10.        end if
    11.  
    12. end sub

    with 15 textboxes i would have to repeat the code 15 times
    now if i had some sort of textbox i could have one routine and call it from every textboxes change method

    something like
    VB Code:
    1. private function call_common_routine(uppervalue,lowervalue,currenttextbox)
    2.        if ((currenttextbox<uppervalue) and (currenttextbox>lowervalue)) then
    3.               error_flag=true
    4.        else
    5.                currenttextbox = 30
    6.                 error_flag = false
    7.        end if
    8. end function



    footext2_change()

    uppervalue = 100
    lowerrvalue = footext3.text
    currenttextbox = footext2.text
    call_common_routine(uppervalue,lowervalue,currenttextbox)
    end sub
    [/Highlight]


    is such a routine possible, passing textboxes, the way i do it it just copies the textbox contents to variable and passes it, i wanted to pass the current textbox "handle(?)" to the common routine.
    Last edited by vb_student; Sep 24th, 2005 at 11:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width