CompuServe Thread

#A Compute Function

3 messages in this thread
#3248From: Ron GrantOct 15, 1991 3:20 PM
I am working on relatively complicated application where attributes (Fonts, Sizes, Captions, Text, Etc.) are constantly being changed by the user on a particular form. I have 60+ Controls on the form. Is there a way to grab a handle or variable name of a control pass is to a single subroutine or function and have it process on the control. At this point I am forced code each individual object individually. For instance I have a dialog box with scroll bars that move controlon a different form around. To get the scroll bar form the user double clicks on a field, picture or label on the target form. Ideally this functionally would work like this SUB Caption10_DoubleClick handle = CTLName MoverDLG.Show End Sub The Scrolling control from could then work with the handle: Sub SB_Change handle.Top = SB_Change+handle.Top End Sub Obviously this methodology doesn't work. . . Most languages I've worked with have this capability, COBOL has a compute statement, dBase uses an & prefix to execute the contents of a string. At this point my apps are twice as large as they sould be because I'm having to code controls individually. Am I missing something???? Any ideas????????? There are 2 Replies.
#3334From: Jonathan Zuck (UFI)Oct 15, 1991 11:09 PM
Ron, Can you use ActiveControl for this purpose? -=- Jonathan
#3356From: Keith Funk/Vanc.BC,CAN.Oct 16, 1991 1:21 AM
Hi Ron, <<Is there a way to grab a handle or variable name of a control and pass it to a subroutine…>> You bet.<g> And it's just as easy as passing a variable. Call the subroutine using the control's CtlName, eg. Call PrintHello(Text1). The PrintHello routine would look like this. Sub PrintHello(TextBox As Control) TextBox.Text = "Hello" End Sub You can even pass a Form name. An additional feature of VB that adds extra power to the capability of passing controls is the If condition, IF TypeOF object Is objecttype. This is described in the VB Language Reference pp. 20 and 149. Hope this helps. KeithF