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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Windows Calculator

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Hi,

I want to open up windows calculator from my form instead of making one so i created a new module and put this code in:
Sub LoadEXE(Dir As String)
X% = Shell(Dir, 1): NoFreeze% = DoEvents(): Exit Sub
End Sub

and attached this code to a button on the form:
Private Sub cmdCalculator_Click()
LoadEXE "C:\WINDOWS\calc.exe"
End Sub

and when i try it, the form opens the calculator but this error box pops up saying:
Run-time error '6':
Overflow

Anyone know what I'm doing wrong?

Thanks....
 
X is being used as an integer and in the 32bit operating envirnoment, you can't shell a 32bit app with an integer. Change X to a Long and it should work fine, i.e., Dim X as Long
X = Shell(yada yada yada)
 
Or why not just type

Shell "C:\Calc.exe"

and this will do exactly the same thing and give no errors

It works for me at least
 
Hi,

Generally, you would want to evaluate the program's task id which is returned by the shell function as opposed to using the shell statement.

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top