[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Running into the unknown

Posted on 2000-01-31
5
Medium Priority
?
178 Views
Last Modified: 2010-05-02
I wish to run a Program that was typed in Text1 By the user.  I can't seam to find a way to turn Text1.text into Variable (A) and use it in the ShellExecute (A) command. Am I going about it the wrong way?
0
Comment
Question by:R_N_WARD
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
cable4096 earned 80 total points
ID: 2468001
I guess you mean the shell() command? Try this:

Private Sub Command1_Click()
    Dim a As String
    Dim l As Long
    a = "" & Form1.Text1.Text
    l = Shell(a, vbMaximizedFocus)
End Sub

It uses a button, named Command1, and on the Click event it reads Text1.Text into variable a, which is a string. This is passed to the shell() function to run the program in a Maximized Focus so you can see it.
0
 

Author Comment

by:R_N_WARD
ID: 2468582
You answer works, but I have a new prob.  My progam consits of Comand1 (dubed "run"), drive1, Text1, dir1 and file1. I want the user to be able to use the drive1, file1, and dir1 to select the file (*that is suposed to apper in text1*) and press run to, well, run the program. The file will not appear in Text1. Any helpful hints.
0
 

Author Comment

by:R_N_WARD
ID: 2468621
You answer works, but I have a new prob.  My progam consits of Comand1 (dubed "run"), drive1, Text1, dir1 and file1. I want the user to be able to use the drive1, file1, and dir1 to select the file (*that is suposed to apper in text1*) and press run to, well, run the program. The file will not appear in Text1. Any helpful hints.
0
 

Author Comment

by:R_N_WARD
ID: 2470903
see above
0
 
LVL 1

Expert Comment

by:cable4096
ID: 2483310
Try this:

Private Sub Command1_Click()
    Dim a As String
    Dim l As Long
    Dim s_temp as String
    s_temp = "" & Form1.drive1 & Form1.dir1 & Form1.file1
    Form1.Text1.Text = s_temp
    a = "" & Form1.Text1.Text
    l = Shell(a, vbMaximizedFocus)
End Sub

That is assuming that the user uses all the right settings, as in:

drive1 = "C:\"
dir1 = "Windows\Command"
file1 = "edit"

Which would make s_temp as "C:\Windows\Command\edit"

Which Text1 gets set to.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

591 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