For example in figure, but complains request object,
Only the control name as a string passed through controls, have bigwigs doubt dispels doubts, is why,
The couple only 20 points, laughed
CodePudding user response:
If nothing else, your sub TTT () code is wrong!
Is a "type" of the object, and a. istcount (assuming the arguments have this attribute) type must be "integer,"
Just think: a "integer", is assigned to an Object???????
CodePudding user response:
Don't know can write c #,
CodePudding user response:
Figure?
Figure?
Figure?
CodePudding user response:
Try this:
Sub TTT (byref obj as object) Msgbox obj. Listcount End sub Sub (tt) TTT (fmdatamerge lblot) End sub CodePudding user response:
Parameter declaration is a pointer to the object is an object, rather than a string, the inside of the code name string just to let people see, after compiling, these names are all kinds of objects, the memory address register, this is to let the CPU, so if you send a clear name inside are not enough, unless you again inside the function name and object corresponding transformation,
If you say the name, there is a CallByName specific usage check MSDN, it is only a method can use a string to the property of an object call, still need to use a pointer to object itself,
CodePudding user response:
reference 1/f, a toast to invite the bright moon response: if nothing else, your sub TTT () code is wrong! Is a "type" of the object, and a. istcount (assuming the arguments have this attribute) type must be "integer," Just think: a "integer", is assigned to an Object??????? a=a. istcount is I write wrong, with other variables also can not CodePudding user response:
reference 4 floor milaoshu1020 response: try this: Sub TTT (byref obj as object) Msgbox obj. Listcount End sub Sub (tt) TTT (fmdatamerge lblot) End sub also can not CodePudding user response:
refer to fifth floor crispy big ice cream reply: parameter declaration is a pointer to the object is an object, rather than a string, the inside of the code name string just to let people see, after compiling, these names are all kinds of objects, the memory address register, this is to let the CPU, so if you send a clear name inside are not enough, unless you again inside the function name and object corresponding transformation, If you say the name, there is a CallByName specific usage check MSDN, it is only a method can use a string to the property of an object call, still need to use a pointer to object itself, thank you, can see some, to use pointer into itself to want to use what method, can simply said a minute thinking, actually I meant, for example: there are multiple buttons the same functionality, but involves the listbox is different, I want to write a piece of code, only by the name of relay control method, CodePudding user response:
I just wrote a piece of code to test the, Find your "mistake" reason is your code written, You put the line of code: the TTT (tt) To: call TTT (tt) Try it or remove the parentheses, CodePudding user response:
refer to the eighth floor weixin_44196531 response: Quote: refer to fifth floor crispy big ice cream reply: parameter declaration is a pointer to the object is an object, rather than a string, the inside of the code name string just to let people see, after compiling, these names are all kinds of objects, the memory address register, this is to let the CPU, so if you send a clear name inside are not enough, unless you again inside the function name and object corresponding transformation, If you say the name, there is a CallByName specific usage check MSDN, it is only a method can use a string to the property of an object call, still need to use a pointer to object itself, thank you, can see some, to use pointer into itself to want to use what method, can simply said a minute thinking, actually I meant, for example: there are multiple buttons the same functionality, but involves the listbox is different, I want to write a piece of code, only by the name of relay control method, Think you need is a control array CodePudding user response:
Take off pants break wind ways using a string called object: Form two textbox, a button, try the following code Option Explicit Dim allCtl As New Collection Private Sub Form_Load () Dim CTL 'initialization, put all controls in the collection, and the control name as an object of the index key For Each CTL In Me. Controls, AllCtl. Add CTL, CTL. Name Next End Sub Private Sub Command1_Click () Call the test (" Text1 ", "this is a test") Call the test (" Text2 ", "test results look here") End Sub Private Sub test (ByVal strObj As String, ByVal strDisp As String) 'control name was used to extract the control object and action object text attribute AllCtl (strObj). The Text=strDisp End Sub CodePudding user response:
Back to the 9th floor, I tried, really has something to do with the brackets! Add the error on the brackets, don't understand; Back upstairs, is really take off pants break wind, because Controls can Controls (" Name "), so doesn't put them in the collection; The code is as follows: Option Explicit Private Sub Command1_Click () Tt End Sub Sub TTT (ByRef obj As Object) MsgBox obj. ListCount End Sub Sub (tt) TTT fmDataMerge. LbLot 'any TTT (fmDataMerge. LbLot) will go wrong! End Sub Private Sub Command2_Click () Controls (" lbLot ".) AddItem Rnd End Sub Run the example: Download address: Link: https://pan.baidu.com/s/1dwPn-IT-gpr9C2oA1swWtg The extracted code: e1p7 CodePudding user response:
Back upstairs TTT x represents the arguments of tt TTT (x) represents the is the argument of (x) expression () here is operator, and because of expression is the result stored in temporary variables, and the call of a different parameter error of course!! So don't use TTT (x) this orthography Either TTT x Either Call TTT (x)nullnullnullnullnullnullnullnull