To achieve this, follow the steps below:
import System;
import System.Drawing;
import Accessibility;
import System.Windows.Forms;
class EventTestForm extends Form
{
var btn : Button;
var tbx : TextBox;
var tbx2 : TextBox;
var equ;
var equ2;
function EventTestForm()
{
tbx = new TextBox;
tbx2 = new TextBox;
tbx.Top = 21;
btn = new Button;
btn.Top=42;
btn.Text = "Fire Event";
Controls.Add(btn);
Controls.Add(tbx);
Controls.Add(tbx2);
// Connect the function to the event.
btn.add_Click(ButtonEventHandler1);
}
// Add an event handler to respond to the Click event raised
// by the Button control.
function ButtonEventHandler1(sender, e : EventArgs)
{
equ = Convert.ToInt32(tbx.Text);
equ=int.Parse(tbx.Text);
equ2 = Convert.ToInt32(tbx2.Text);
equ2=int.Parse(tbx2.Text);
MessageBox.Show(equ+equ2);
}
}
Application.Run(new EventTestForm);
Instructions for compiling:
1. Navigate to your .NET framework directory.
2. Locate jsc.exe within the folder.
3. Add its location to your system's environmental variable "path".
4. Save this code as calc.js
5. Open command prompt and navigate to the folder where calc.js is saved.
6. Type jsc calc.js
7. Run calc.exe.