Solved

How do i create a script for an array

Posted on 2006-11-29
12
144 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
Comment Utility
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
Comment Utility
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 62

Expert Comment

by:Fernando Soto
Comment Utility
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Author Comment

by:TAMSCODAN
Comment Utility
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
Comment Utility
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
Comment Utility
How would you do it with a Grid and What should i declare as a Variable?
0
 
LVL 85

Expert Comment

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

Author Comment

by:TAMSCODAN
Comment Utility
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
Comment Utility
Click on Help --> About...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now