Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,162 of 10,840    |
|    Steve Gerrard to Amanda    |
|    Re: text box calculation    |
|    22 Jan 05 02:01:56    |
   
   From: mynamehere@comcast.net   
      
   "Amanda" wrote in message   
   news:41f131ce_2@mk-nntp-2.news.uk.tiscali.com...   
   | Help,   
   |   
   | I am new to visual basic programming and I was wondering how to allow   
   a   
   | textbox   
   | to do a calculation by pressing enter   
   |   
   | ie I want to type the following into a textbox 25.2 * 2 press enter   
   on the   
   | keyboard   
   | and the textbox to display 50.4 Any Ideas ???????   
   |   
   |   
      
   Do you have the Microsoft Script Control in your list of components? If   
   so, then add one to your form. You then just need this simple event   
   handler:   
      
   Private Sub Text1_KeyPress(KeyAscii As Integer)   
    If KeyAscii = vbKeyReturn Then   
    On Error Resume Next   
    Text1.Text = ScriptControl1.Eval(Text1.Text)   
    End If   
   End Sub   
      
   You might want to make Text1 multi-line, so you don't get a beep when   
   you press enter.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca