Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Functions in an ActiveX Control

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm trying to use a function to pass a value to an activeX control from a VBScript. The problem i run into is that in my VBScript i have:

Dim challengecopyobj
Dim challenge
challenge = "Hello"
Set challengecopyobj = CreateObject("clipboard3.GetCh")
challengecopyobj.GetCh(challenge)

and i keep getting the error that "Error: Object doesn't support this property or method: "challengecopyobj.GetCh(challenge)"

see my main concern is to be able to pass a value to an activeX control but i haven't been successful in doing that yet. Also i'm not using this VBScript in a HTML file. It is just a script that i'm creating for use of a telnet client. Most of the information online is all about webpage development using activeX and VBScript. Can anyone help me with this?

Kenji


 
If you want to pass a value to an ActiveX control, the best way to do this is to use Properties.

Lets say you want to create the property challenge, and that it is a data type of String.

First, the property is writeable, so you define a Property Let procedure in your control.

Option Explicit

Dim mschallenge as String ' used to store the value of the property

Public Property Let challenge(Byval sData As String)
mschallenge = sData
End Property


Second, the property is readable, so add the following code to the above:

Public Property Get challenge() As String
challenge = mschallenge
End Property


This is a good start for you, but then you have to consider persistence of properties and start writing to and reading from the property bag.

To access this property in your application, you would use:

Dim sChallenge As String
sChallenge = challengecopyobj.challenge


to read the property of the control, and you would use:

challengecopyobj.challenge = "challenge"

to write to the property.

To access functions, define the functions in your control in the normal way:

Public Function Function_Name(arguments) As Whatever
' do your stuff
End Function


Then, in your app, you call the function by:

Call challengecopyobj.Function_Name(arguments)

The error that you are getting means that the fuction that you are trying to call has not been coded in the control. (You may have incorrect spelling of the function name)

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top