Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > how to send message to Calculator !!!


Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2005, 02:15 AM
JtheD's Avatar
JtheD JtheD is offline
Centurion
 
Join Date: Sep 2003
Posts: 142
Question 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
Reply With Quote
  #2  
Old 02-27-2005, 05:09 AM
Hugh Lerwill Hugh Lerwill is offline
Junior Contributor
 
Join Date: Oct 2004
Posts: 292
Default

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,
Reply With Quote
  #3  
Old 03-02-2005, 10:18 PM
JtheD's Avatar
JtheD JtheD is offline
Centurion
 
Join Date: Sep 2003
Posts: 142
Default

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
Reply With Quote
  #4  
Old 03-02-2005, 10:44 PM
Bcoloutlaw Bcoloutlaw is offline
Newcomer
 
Join Date: Mar 2005
Posts: 24
Default

try this simple but effective code:

Shell ("calc", vbNormalFocus)
sendkeys text1.text


-Bcoloutlaw
Reply With Quote
  #5  
Old 03-02-2005, 10:47 PM
JtheD's Avatar
JtheD JtheD is offline
Centurion
 
Join Date: Sep 2003
Posts: 142
Default

I GOT it men, just commented this line and

Code:
SendKeys "%{F4}", True
by the way thanks again......
Reply With Quote
  #6  
Old 03-02-2005, 10:50 PM
JtheD's Avatar
JtheD JtheD is offline
Centurion
 
Join Date: Sep 2003
Posts: 142
Default

GREAT JOB Bcoloutlaw,

I can't get simpler then this one thanks for all of you for replying quickly
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->