 |

02-27-2005, 02:15 AM
|
 |
Centurion
|
|
Join Date: Sep 2003
Posts: 142
|
|
how to send message to Calculator !!!
|
hello,
i have a problem,i want to send the value of text box to calculator , i.e. (calculator.display = text1.text) is it possible for me to achieve this, if yes how , please help me , thanks in advance
|
|

02-27-2005, 05:09 AM
|
|
Junior Contributor
|
|
Join Date: Oct 2004
Posts: 292
|
|
Quote:
|
Originally Posted by JtheD
hello,
i have a problem,i want to send the value of text box to calculator , i.e. (calculator.display = text1.text) is it possible for me to achieve this, if yes how , please help me , thanks in advance
|
JtheD,
The following bit of test code may be of interest.
Code:
' copy this into a new form having a CommandButton, a label (lbResult) and a TextBox (CalcTextBox)
' Enter formula into TextBox, Click button, result appears in label
Option Explicit
DefLng A-Z
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
CalcTextBox Text1
Me.ZOrder
End Sub
Sub CalcTextBox(Tb As TextBox)
Dim a$, b$, i
a$ = Tb
If Len(a$) > 0 Then
If FindWindow(0&, "calculator") Then
AppActivate "calculator"
Else
On Error Resume Next
Shell "calc.exe", vbNormalFocus
End If
SendKeys "{DEL}", True
If Err = 0 Then
For i = 1 To Len(a$)
b$ = Mid$(a$, i, 1)
Select Case b$
Case "+", "(", ")"
b$ = "{" + b$ + "}"
End Select
SendKeys b$, True
Next
SendKeys "=", True
SendKeys "^C", True
LbResult = Clipboard.GetText
SendKeys "%{F4}", True
End If
End If
End Sub
regards Hugh,
|
|

03-02-2005, 10:18 PM
|
 |
Centurion
|
|
Join Date: Sep 2003
Posts: 142
|
|
|
thanks Hugh Lerwill, for your quick and correct reply,
what if , i want to get Calculator as Active focus, instead of back on to the form
|
|

03-02-2005, 10:44 PM
|
|
Newcomer
|
|
Join Date: Mar 2005
Posts: 24
|
|
|
try this simple but effective code:
Shell ("calc", vbNormalFocus)
sendkeys text1.text
-Bcoloutlaw
|
|

03-02-2005, 10:47 PM
|
 |
Centurion
|
|
Join Date: Sep 2003
Posts: 142
|
|
I GOT it men, just commented this line and
Code:
SendKeys "%{F4}", True
by the way thanks again......
|
|

03-02-2005, 10:50 PM
|
 |
Centurion
|
|
Join Date: Sep 2003
Posts: 142
|
|
GREAT JOB Bcoloutlaw,
I can't get simpler then this one  thanks for all of you for replying quickly
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|