Home > Software engineering >  How to define the object type of public variables
How to define the object type of public variables

Time:09-23

I want to define the type of an object of public variables, but the transfer failed, the code is as follows:
As the object of public doc
Public range1 as object

Private sub officecontrol1_ondocumentopened (byval file as string, byval document as object) 'third party OCX control provides the function of
The set of doc=document
The set range1=doc. Range (start:=0, end:=10)
End sub

Private sub command2_click ()
Text3. Text=doc. Range (start:=0, end:=10) 'there will not be able to quote, error message "object variables"
Text4. Text=range1 'here is empty has not passed the result of the
End sub

Question 2: can't define dim doc as new object, I am using VB6.0 by use the lite version, what's the problem

CodePudding user response:

That estimate is: doc object is empty, if you monitor your doc transfer success,

CodePudding user response:

refer to the original poster tantanln response:
I want to define the type of an object of public variables, but the transfer failed, the code is as follows:
As the object of public doc
Public range1 as object

Private sub officecontrol1_ondocumentopened (byval file as string, byval document as object) 'have third-party OCX control provides a function of
The set of doc=document
The set range1=doc. Range (start:=0, end:=10)
End sub

Private sub command2_click ()
Text3. Text=doc. Range (start:=0, end:=10) 'there will not be able to quote, error message "object variables"
Text4. Text=range1 'here is empty has not passed the result of the
End sub

Question 2: can't define dim doc as new object, I am using VB6.0 by use the lite version, what's the problem


Now that is a function of the "third party", how can have "their own code"?
If private sub officecontrol1_ondocumentopened () are you writing your own code,
You try to put the second parameter by: byval byref instead (or don't write transfer mode),

Question 2: is spelled wrong!!!!
Behind the new should be with concrete, can be directly instantiated class (class name),
If it is "Object" type, should be write like this: dim doc as Object

CodePudding user response:

Now that is a public variable, you don't need to transfer, need to place directly using the
Object is an abstract class, not new directly, also can not all classes to new

CodePudding user response:

Public variables to define in the module. (bas),
  • Related