Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create a form using VB script?

Posted on 2009-04-10
6
Medium Priority
?
1,207 Views
Last Modified: 2012-05-06
HI,
i need to create a usr form with some option buttons,2 text boxes and two buttons.

how to do this?Help pls
0
Comment
Question by:ArunAchudh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 5

Accepted Solution

by:
brandonvmoore earned 90 total points
ID: 24120991
If you don't know enough about VB Script to do this, then I would strongly suggest that you learn javascript instead as vbscript is only compatible with IE browsers.  Use javascript so other browsers can view your form too.  Go to w3schools.com and you'll find some tutorials that you can go through that are very short and concise.  If you absolutely need to use VB Script they have tutorials on that as well.

I assume that you will actually want to 'do' something with your form controls, so me just giving you the code to make a form that has these controls won't be very helpful.  The tutorials won't take you very long to go through.
0
 

Author Comment

by:ArunAchudh
ID: 24121001
No. actually i am using a atutomation test tool which works using VB script. i just want a from displaying options to be listed to the users adn the user can select which test to run.

so VB script is the must in this case.
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24121010
Same answer: go to w3schools.com.  They've got code there you can copy and paste.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24121026
Oh, I should clarify something for you though.  What you are wanting to do doesn't require the use of VB Script.  It's just HTML code.  And when I say it doesn't require VB script, I don't mean that you 'could' do it with VB Script but that it's easier to just use VB Script.  I mean that making a form with controls has nothing to do with VB Script.  You can use VB Script to manipulate forms and controls, but VB script does not create them, HTML does.
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24121029
Sorry, one of the sentences in my above post doesn't quite make sense.  It should read:

... but that it's easier to just use "HTML" ...
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 24121635
this is an example of vbscript for wmi queries of BIOS properties, but it should get you to the point
on how to create a form
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Management
 
Namespace WMISample
 
    Public Class MyQuerySample 
        Inherits System.Windows.Forms.Form
 
        Friend WithEvents userNameLabel As System.Windows.Forms.Label
        Friend WithEvents userNameBox As System.Windows.Forms.TextBox
        Friend WithEvents passwordBox As System.Windows.Forms.TextBox
        Friend WithEvents passwordLabel As System.Windows.Forms.Label
        Friend WithEvents OKButton As System.Windows.Forms.Button
        Friend WithEvents closeButton As System.Windows.Forms.Button
        
        Private components As System.ComponentModel.IContainer
 
        Public Sub New()
            MyBase.New()
 
            InitializeComponent()
        End Sub
 
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
 
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 
            Me.userNameLabel = new System.Windows.Forms.Label
            Me.userNameBox = new System.Windows.Forms.TextBox
            Me.passwordBox = new System.Windows.Forms.TextBox
            Me.passwordLabel = new System.Windows.Forms.Label
            Me.OKButton = new System.Windows.Forms.Button
            Me.closeButton = new System.Windows.Forms.Button
            Me.SuspendLayout()
            ' 
            ' userNameLabel
            ' 
            Me.userNameLabel.Location = New System.Drawing.Point(16, 8)
            Me.userNameLabel.Name = "userNameLabel"
            Me.userNameLabel.Size = New System.Drawing.Size(160, 32)
            Me.userNameLabel.TabIndex = 0
            Me.userNameLabel.Text = "Enter the user name for the remote computer:"
            ' 
            ' userNameBox
            ' 
            Me.userNameBox.Location = New System.Drawing.Point(160, 16)
            Me.userNameBox.Name = "userNameBox"
            Me.userNameBox.Size = New System.Drawing.Size(192, 20)
            Me.userNameBox.TabIndex = 1
            Me.userNameBox.Text = ""
            ' 
            ' passwordBox
            ' 
            Me.passwordBox.Location = New System.Drawing.Point(160, 48)
            Me.passwordBox.Name = "passwordBox"
            Me.passwordBox.PasswordChar = "*"
            Me.passwordBox.Size = new System.Drawing.Size(192, 20)
            Me.passwordBox.TabIndex = 3
            Me.passwordBox.Text = ""
            ' 
            ' passwordLabel
            ' 
            Me.passwordLabel.Location = new System.Drawing.Point(16, 48)
            Me.passwordLabel.Name = "passwordLabel"
            Me.passwordLabel.Size = new System.Drawing.Size(160, 32)
            Me.passwordLabel.TabIndex = 2
            Me.passwordLabel.Text = "Enter the password for the remote computer:"
            ' 
            ' OKButton
            ' 
            Me.OKButton.Location = New System.Drawing.Point(40, 88)
            Me.OKButton.Name = "OKButton"
            Me.OKButton.Size = new System.Drawing.Size(128, 23)
            Me.OKButton.TabIndex = 4
            Me.OKButton.Text = "OK"
            ' 
            ' closeButton
            ' 
            Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.closeButton.Location = New System.Drawing.Point(200, 88)
            Me.closeButton.Name = "closeButton"
            Me.closeButton.Size = New System.Drawing.Size(128, 23)
            Me.closeButton.TabIndex = 5
            Me.closeButton.Text = "Cancel"
            ' 
            ' MyQuerySample
            ' 
            Me.AcceptButton = Me.OKButton
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.CancelButton = Me.closeButton
            Me.ClientSize = New System.Drawing.Size(368, 130)
            Me.ControlBox = false
            Me.Controls.Add(Me.closeButton)
            Me.Controls.Add(Me.OKButton)
            Me.Controls.Add(Me.passwordBox)
            Me.Controls.Add(Me.passwordLabel)
            Me.Controls.Add(Me.userNameBox)
            Me.Controls.Add(Me.userNameLabel)
            Me.Name = "MyQuerySample"
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
            Me.Text = "Remote Connection"
            Me.ResumeLayout(false)
 
        End Sub
 
        Public Overloads Shared Function Main() As Integer
 
            Application.Run(New MyQuerySample)
        End Function
 
        Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
        
            Try
                Dim connection As New ConnectionOptions
                connection.Username = userNameBox.Text
                connection.Password = passwordBox.Text
                connection.Authority = "ntlmdomain:DOMAIN"
 
                Dim scope As New ManagementScope( _
                    "\\FullComputerName\root\CIMV2", connection)
                scope.Connect()
 
                Dim query As New ObjectQuery( _
                    "SELECT * FROM Win32_BIOS") 
 
                Dim searcher As New ManagementObjectSearcher(scope, query) 
 
                For Each queryObj As ManagementObject in searcher.Get()
 
                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("Win32_BIOS instance")
                    Console.WriteLine("-----------------------------------")
                Next
 
                Close()
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            Catch unauthorizedErr As System.UnauthorizedAccessException
 
                MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message)
            End Try
        End Sub
 
        Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
 
            Close()
        End Sub
    End Class
End Namespace

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question