Link to home
Start Free TrialLog in
Avatar of wahooo
wahooo

asked on

Totally Newbie, active x control

Hi,

I have an .asp (sql2000) web application.
I have VBStudio 6.0 installed, and I am totally new to this stuff. Need just code, donot have time to learn VB now unfortunately.
Want to create an activeX control that runs on my web-application.
I have one phonenumber in my asppage say: <% phonenumber = "12345678" %>

I want an activex-control that grabs this phone number and sends it to the command line with this command:
c:\program files\x-pro\x-pro.exe "12345678"

(the number changes each time).

I think this is possible. To use shell command in the asp-page does not work because of security issues.

(But I am in control of all the users machines that will use this web -application so I can do anything on the clients pc's if that is needed).

Best regards

Sjur
Avatar of anv
anv

hi

open a new Vb Project

choose Activex Control from the Project Options..

in the Code window..of the User Control...just added into the project..

add an Event Like This

Public Event CallShell(PhNo As String)


add a command button to the control..
in the click event of this command button add code to raise the event

like this..

Dim phno As String

Public Event CallShell(phno As String)

Private Sub Command1_Click()
    RaiseEvent CallShell(phno)
End Sub

Public Property Get SetPhno() As String
     SetPhno = phno
End Property

Public Property Let SetPhno(ByVal vNewValue As String)
    phno = vNewValue
End Property

also, inthe above code i've created a property for the usercontrol..to set the phone number..

save the Project and user control...give any name u want..(say ShellExecutionControl)

now from the file menu..choose make ShellExecutionControl.ocx (or Whatever name u have given to ur project)

add a new project to test ur control...


from project menu choose components..

choose the user control..u just created above...

it'll be available in the list once u ve chosen make <anyNAme>.ocx from the file menu of the user control project...

u can see the component is added into the control box oif the the Standard EXe project u r working on now...

and add following code..

Private Sub Form_Load()
    UserControl11.SetPhno = "363634"
End Sub

Private Sub UserControl11_CallShell(PhNo As String)
   MsgBox PhNo
End Sub


hope its not so confusing...

try ..this..

and let me know if u have any doubt...

'ive just added a message box..if u want u can add a shell command ...

like this

Private Sub UserControl11_CallShell(PhNo As String)
   shell "c:\program files\x-pro\x-pro.exe " & phno
End Sub
Avatar of wahooo

ASKER

Hi, thanks for fast reply..

I created new activex-control..

is this the code I should paste in..?

Dim phno As String

Public Event CallShell(phno As String)

Private Sub Command1_Click()
    RaiseEvent CallShell(phno)
End Sub

Public Property Get SetPhno() As String
     SetPhno = phno
End Property

Public Property Let SetPhno(ByVal vNewValue As String)
    phno = vNewValue
End Property


in the view code

or is it more to it?

sjur (I will then go to step to in the above text:)
Avatar of wahooo

ASKER

think i did it right..but i get error when i am testing:

runtime error 424  object required
debug goes to this line:

UserControl11.SetPhno = "363634"

testing code:
Private Sub Form_Load()
    UserControl11.SetPhno = "363634"
End Sub

Private Sub UserControl11_CallShell(PhNo As String)
   MsgBox PhNo
End Sub

The name of the files i saved is shellexecutioncontrol).exe and so on..

I got the ')' with me on the paste..does this **** up the code?

Sjur
Avatar of wahooo

ASKER

Ok, think I got everything to work, but nothing happens when I test..nothing, I see the command button, but when onclick, nothing triggers..

Sjur
hi wahooo

Please Check if the Name u have given to ur UserControl is UserControl1 ..(which is actually the Default name )..u can change it to anythig else u want. to..give..

 
hi wahooo

the Name of the Project is the Logical Name not the Physical name that u'll be getting in the Components List...

can i see ur code please??
Avatar of wahooo

ASKER

I think the thing is..i have not added any shell command..
nowhere in the code so far is the c:... command prompt line..

where should i put:

Private Sub UserControl11_CallShell(PhNo As String)
   shell "c:\program files\x-pro\x-pro.exe " & phno
End Sub

to try if it works..
Avatar of wahooo

ASKER

Here is the code:

Dim phno As String

Public Event CallShell(phno As String)

Private Sub Command1_Click()
    RaiseEvent CallShell(phno)
End Sub

Public Property Get SetPhno() As String
     SetPhno = phno
End Property

Public Property Let SetPhno(ByVal vNewValue As String)
    phno = vNewValue
End Property
alright ..this is what u ve added into the ActiveX Control u 've Created..rt?

what abt the Code where u r testing the control...

the code in the Standard Exe where u r testing it...

can u paste that too..
Avatar of wahooo

ASKER

Yes, the name is:  UserControl1

sjur
Avatar of wahooo

ASKER

Standard Exe code:

Private Sub Form_Load()
    UserControl11.SetPhno = "363634"
End Sub

Private Sub UserControl11_CallShell(PhNo As String)
   MsgBox PhNo
End Sub


hi Sjur

did u get any message box when u run the test project??

can i get the code where u r testing ur control?
hi Sjur

here in ur code..u r using UserControl11 instead of UserControl1..

did u give theh name to ur User Control here in the Test Project as

UserControl11 or what??
Avatar of wahooo

ASKER

It opens a browser: source code:
<HTML><BODY><OBJECT classid="clsid:E61CFE4F-2B33-4AD2-9FDF-A6FAF10AC807">
</OBJECT></BODY></HTML>


Shows a button with command1, but no message..
could it have something to do with my security settings in iexplorer..
I will try to change them now to low and try again..

Avatar of wahooo

ASKER

I just copyed the code in your first post..

Private Sub Form_Load()
    UserControl11.SetPhno = "363634"
End Sub

Private Sub UserControl11_CallShell(PhNo As String)
   MsgBox PhNo
End Sub

hi Sjur

instead of teh message ..add the shell command in the UserControl1_CallShell(phno As string) event..

Also ..whenever u make any  changes to ur control...u need to recompile it..or u need to repeat this step:

from file menu of the control project...

choose Make <anyName>.ocx
Avatar of wahooo

ASKER

Ok, I got it to work..thanks very much..

How do I call the activex function from my .asp page and pass the variable to it?

Must the activex-control be on the webserver or the client machine

sjur
ASKER CERTIFIED SOLUTION
Avatar of anv
anv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wahooo

ASKER

ok, i will give you points here anyway..but do you know the code for doing this in asp-page..or do I need to start another question:)

sjur
Accept my answer...

check the author's comment before making any decision...