Comments

jetdv wrote on 5/10/2003, 5:00 PM
Short answer - yes (see excalibur). But it will may take more than one line of code.
roger_74 wrote on 5/11/2003, 4:21 AM
Forms can be tricky when you're first starting out.

Here's an example I converted to JScript.Net from C#


import System;
import System.Drawing;
import System.Collections;
import System.ComponentModel;
import System.Windows.Forms;

import SonicFoundry.Vegas;

var Input : UserInputForm = new UserInputForm();
Input.ShowDialog();





public class UserInputForm extends System.Windows.Forms.Form
{
private var label1 : System.Windows.Forms.Label;
private var textBox1 : System.Windows.Forms.TextBox;
private var button1 : System.Windows.Forms.Button;

private var components : System.ComponentModel.Container = null;

public function UserInputForm()
{
InitializeComponent();
}

//Clean up any resources being used.
protected override function Dispose(disposing : Boolean)
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
super.Dispose( disposing );
}


private function InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 39);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(48, 23);
this.label1.TabIndex = 0;
this.label1.Text = "Input:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(72, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(248, 20);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(248, 80);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "OK";
this.button1.add_Click(this.button1_Click);
//
// UserInputForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(336, 118);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Name = "UserInputForm";
this.Text = "UserInputForm";
this.ResumeLayout(false);
}

private function button1_Click(sender : Object , e : System.EventArgs)
{
this.Close();
}
}
roger_74 wrote on 5/11/2003, 5:01 AM
By the way, JScript.Net is not Javascript or Java. It has a lot of similarities of course, but it is different.

Everything you need to know about JScript.Net is available here.
richjo100 wrote on 7/23/2004, 8:15 AM
Just wanted to say thanks to roger_74 for helping out on this post! The information included has been very useful
Richard
Nat wrote on 7/29/2004, 1:56 PM
Inputing a value in VB is quite easy using the InputBox function. See below





Imports Sony.Vegas
Imports System.Windows.Forms

Public Module MainModule

Dim Valeur as String
Dim Reponse as Integer
Dim ValeurInt as Integer
Dim Start as String
Dim Counter as Integer

Public Sub Main()
Counter = 0
Reponse = CInt(Int((100 * Rnd()) + 1))
Chiffres()
End Sub

Public Sub Chiffres()
Counter = Int(Counter + 1)
Valeur = InputBox("Enter a number between 1 and 100")
ValeurInt = CInt(Valeur)
Teste()
End Sub

Public Sub Teste()
If ValeurInt = Reponse Then
MessageBox.Show("Good answer ! " & Counter & " attempts")
Debut()
ElseIf ValeurInt < Reponse Then
MessageBox.Show("Higher")
Chiffres()
Else
MessageBox.Show("Lower")
Chiffres()
End If
End Sub

Public Sub Debut()
Start = InputBox("Continue ? (Type Yes or No)")
If Start = "Yes" Then
Main()
ElseIf Start = "yes" Then
Main()
End If
End Sub

End Module

ponchoman1 wrote on 11/30/2004, 10:00 AM
I need to prompt a user for input in a script. I came across this script from roger 74. The script works but I don't know how to get the user input assigned to a variable that I could use in the script. I have never worked with Forms before. Could someone help me out with this? Thx.


I apologize if this is pretty basic stuff.
jetdv wrote on 11/30/2004, 11:35 AM
You can try something like this:


try {

var dlog = new fioDialog();
if (DialogResult.OK == dlog.ShowDialog()) {

var dofront = dlog.chkdofront.Checked;
var doend = dlog.chkdoend.Checked;

}

} catch (e) {
MessageBox.Show(e);
}


class fioDialog extends Form {
var chkdofront : CheckBox;
var chkdoend : CheckBox;


function fioDialog() {
this.Text = "My Form";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
this.Width = 600;

var titleBarHeight = this.Height - this.ClientSize.Height;
var buttonWidth = 80;

chkdofront = addCheckbox("Front Checkbox",1 , 150, 4);
chkdoend = addCheckbox("End Checkbox",1 , 150, chkdofront.Bottom + 4);

//OK & Cancel Buttons
var buttonTop = chkdoend.Bottom + 5;

var okButton = new Button();
okButton.Text = "OK";
okButton.Left = this.Width - (2*(buttonWidth+10));
okButton.Top = buttonTop - 10;
okButton.Width = buttonWidth;
okButton.Height = okButton.Font.Height + 12;
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
AcceptButton = okButton;
Controls.Add(okButton);

var cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Left = this.Width - (1*(buttonWidth+10));
cancelButton.Top = buttonTop - 10;
cancelButton.Height = cancelButton.Font.Height + 12;
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
CancelButton = cancelButton;
Controls.Add(cancelButton);

this.Height = titleBarHeight + okButton.Bottom + 8;

}

function addCheckbox(labelName, checkbox, left, top) {
var label = new Label();
label.AutoSize = true;
label.Text = labelName;
label.Left = left + 18;
label.Top = top + 4;
Controls.Add(label);

if (checkbox == 1) {
var checkbox = new CheckBox();
checkbox.Left = left;
checkbox.Width = 36;
checkbox.Top = top;
Controls.Add(checkbox);

return checkbox;
}
}

}
ponchoman1 wrote on 11/30/2004, 1:00 PM
Great. Thx for the help. I also figured out why I couldn't access the input field in the script from roger 74. I was trying this......

var Date = Input.textBox1.Text

but textBox1 was declared private. once I made it public, it worked.