Solved

How do i create a script for an array

Posted on 2006-11-29
12
167 Views
Last Modified: 2010-04-23
I need to create a Script were i have 3 colums and four rows I will have to put some default numbers in each text box and i guess the part that I really dont understand is how do i make the calculation to multiply down the colum and subtract from each row in a script format; for example

5   | 2   | 3
8   | 32 |1
4   | 9   | 10
17 | 15 | 12

I would like for my script to Multiply 5*8*4*17 and have the answer populate on a popup box and at the same time subract 5-2-3 and the answer populate on the same popup when i presss my calculate button.
0
Comment
Question by:TAMSCODAN
  • 6
  • 5
12 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18037866
Can you define "script" please?

You are working in?

    VBScript (.vbs)
    VB6 (or below)
    VB.Net 2003 (or below)
    VB.Net 2005

"I will have to put some default numbers in each text box"

So you have TextBoxes on a Form already that you are pulling these numbers from?

Give more details...
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 18037901
Well what i am reffering to is the code that I am writing for the form I have 12 total text boxes and they are arranged in three colums and four rows. I am Using Visual Studio using VB.NET 2005. In the code I will need some numbers to be populated by default in all the text boxes such as i explained above.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 18037990
Hi TAMSCODAN;

>> I will need some numbers to be populated by default in all the text boxes such as i explained above.

Will this number be the same each time the form is opened?
Will the default number be the same in each text box?
What are the numbers?
You talk about an array. Is this the arrangement of text boxes or do they have to be in a 2d array?

Fernando
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18038029
If you want default numbers then just set the Text() property of the TextBoxes at design-time in the IDE for each TextBox.

"I would like for my script to Multiply 5*8*4*17 and have the answer populate on a popup box and at the same time subract 5-2-3 and the answer populate on the same popup when i presss my calculate button."

To help with this part we need to know the NAMES and the LAYOUT of the TextBoxes on your form...
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 18038325
I havnt defined the names of the textboxes therefore they currently have the defalt names as TextBox1, TextBox2 and so on
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18038364
Ok.

We still need to know the LAYOUT of them on your form.

TextBox1   TextBox2   TextBox3
TextBox4   TextBox5   TextBox6
TextBox7   TextBox8   TextBox9
TextBox10 TextBox11 TextBox12

or

TextBox1   TextBox5   TextBox9
TextBox2   TextBox6   TextBox10
TextBox3   TextBox7   TextBox11
TextBox4   TextBox8   TextBox12

0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 18038400
This is the way that I set it up

TextBox1   TextBox5   TextBox9
TextBox2   TextBox6   TextBox10
TextBox3   TextBox7   TextBox11
TextBox4   TextBox8   TextBox12
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18038787
Add some Labels:

TextBox1   TextBox5   TextBox9     Label4
TextBox2   TextBox6   TextBox10   Label5
TextBox3   TextBox7   TextBox11   Label6
TextBox4   TextBox8   TextBox12   Label7
Label1       Label2       Label3

Then something like...

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Label1.Text = CInt(TextBox1.Text) * CInt(TextBox2.Text) * CInt(TextBox3.Text) * CInt(TextBox4.Text)
            Label4.Text = CInt(TextBox1.Text) - CInt(TextBox5.Text) - CInt(TextBox9.Text)

            ' similar code for the other columns/rows
            ' ...
        Catch ex As Exception
        End Try
    End Sub

You could probably use a Grid more efficiently instead...
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 18038827
How would you do it with a Grid and What should i declare as a Variable?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18038901
What version VB.Net are you working with?...
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 18038925
I am Unsure its from the Visual Studios 2005. I am at work and i dont know how to check it.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18069249
Click on Help --> About...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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