Improve company productivity with a Business Account.Sign Up

x
?
Solved

How do i create a script for an array

Posted on 2006-11-29
12
Medium Priority
?
198 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 86

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 64

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 86

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 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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 86

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 86

Expert Comment

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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Watch the video to know how one can repair corrupt Exchange OST file effortlessly and convert OST emails to MS Outlook PST file format by using Kernel for OST to PST converter tool. It can convert OST to MSG, MBOX, EML to access them. It can migrate…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…

580 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