[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Totally Newbie, active x control

Posted on 2004-11-08
21
Medium Priority
?
234 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:wahooo
  • 11
  • 9
20 Comments
 
LVL 10

Expert Comment

by:anv
ID: 12530665
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
0
 

Author Comment

by:wahooo
ID: 12530759
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:)
0
 

Author Comment

by:wahooo
ID: 12530821
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
0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 

Author Comment

by:wahooo
ID: 12530920
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
0
 
LVL 10

Expert Comment

by:anv
ID: 12530933
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..

 
0
 
LVL 10

Expert Comment

by:anv
ID: 12530942
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??
0
 

Author Comment

by:wahooo
ID: 12530950
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..
0
 

Author Comment

by:wahooo
ID: 12530953
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
0
 
LVL 10

Expert Comment

by:anv
ID: 12530961
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..
0
 

Author Comment

by:wahooo
ID: 12530968
Yes, the name is:  UserControl1

sjur
0
 

Author Comment

by:wahooo
ID: 12530983
Standard Exe code:

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

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


0
 
LVL 10

Expert Comment

by:anv
ID: 12530993
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?
0
 
LVL 10

Expert Comment

by:anv
ID: 12531001
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??
0
 

Author Comment

by:wahooo
ID: 12531002
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..

0
 

Author Comment

by:wahooo
ID: 12531020
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

0
 
LVL 10

Expert Comment

by:anv
ID: 12531040
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
0
 

Author Comment

by:wahooo
ID: 12531149
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
0
 
LVL 10

Accepted Solution

by:
anv earned 2000 total points
ID: 12531441
hi sjur

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

Like u do with other 3rd party components

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

Client Machine , i Would Say or u u can register it on the web server..ur choice..
0
 

Author Comment

by:wahooo
ID: 12531461
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
0
 
LVL 10

Expert Comment

by:anv
ID: 12816176
Accept my answer...

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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question