472,337 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

VB.NET App: store a value in vb.net at run time

karthickbabu
Is Possible to store a value to declared Variable from Text Box at run time. I want to store a value from Text Box in 2 dimension array. First Value can be sotred in variable(0,0). If i press enter text box will be cleared and get another number and it stored in variable(0,1) and so on

I try like this, but not working any problem in this code
Expand|Select|Wrap|Line Numbers
  1.          For i As Integer = 0 To 1
  2.               For j As Integer = 0 To 1
  3.                    FirstMatrixArray(i, j) = Val(txtInput.Text)
  4.                        txtInput.Text = ""
  5.                        txtInput.Focus()
  6.                    End If
  7.                Next
  8.          Next 
  9.  
Let me know your idea about this

Hope your reply
Dec 3 '07 #1
4 2666
CyberSoftHari
487 Expert 256MB
The code you done will update the 2d array every time you trigger the enter.
1. Give i and j declaration as private in that class.
2. Increment i and j value after enter press (in key press event).
3. write assignment statement for FirstMatrixArray(i, j) in key press event after FirstMatrixArray index changed.
Dec 3 '07 #2
I tried all possible ways. But i couldnt get anything. Let me give any example it will help to me.

The code you done will update the 2d array every time you trigger the enter.
1. Give i and j declaration as private in that class.
2. Increment i and j value after enter press (in key press event).
3. write assignment statement for FirstMatrixArray(i, j) in key press event after FirstMatrixArray index changed.
Dec 6 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
use variables i and j in the class (class variables)

and use the button click event (users hits enter / clicks the button to submit the value)

set i and j to 0 on the load of the form.

Expand|Select|Wrap|Line Numbers
  1. int i = 0, j = 0;
  2. int maxi = 2, maxj = 2;
  3. int[,] matrixArr = new int[maxi,maxj];
  4.  
  5. private void btnSubmitValue_Click(object sender,  EventArgs e)
  6. {
  7.    this.matrixArr[i,j] = this.txtInput.Text;
  8.    j++;
  9.    if(j >= this.maxj)
  10.    {
  11.        j = 0;
  12.        i++;
  13.    }
  14.    if(i >= this.maxi)
  15.    {
  16.        //array has been filled if it reaches this line
  17.        this.txtInput.Enabled = false;
  18.        this.btnSubmit.Enabled = false;
  19.    }
  20. }
I have used an online converter to convert it to vb .net, but havent tested it

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer =  0,j As Integer =  0 
  2. Dim maxi As Integer =  2,maxj As Integer =  2 
  3. Dim matrixArr(,) As Integer =  New Integer(maxi,maxj) {} 
  4.  
  5. Private  Sub btnSubmitValue_Click(ByVal sender As Object, ByVal e As EventArgs)
  6.    Me.matrixArr(i,j) = Me.txtInput.Text
  7.    j = j + 1
  8.    If j >= Me.maxj Then
  9.        j = 0
  10.        i = i + 1
  11.    End If
  12.    If i >= Me.maxi Then
  13.        'array has been filled if it reaches this line
  14.        Me.txtInput.Enabled = False
  15.        Me.btnSubmit.Enabled = False
  16.    End If
  17. End Sub
Dec 6 '07 #4
Hi
Thanks I got some ideas from your code. I will try this code. Surely it will be help to me. I reply after i test this code with my code

Once again thanks



use variables i and j in the class (class variables)

and use the button click event (users hits enter / clicks the button to submit the value)

set i and j to 0 on the load of the form.

Expand|Select|Wrap|Line Numbers
  1. int i = 0, j = 0;
  2. int maxi = 2, maxj = 2;
  3. int[,] matrixArr = new int[maxi,maxj];
  4.  
  5. private void btnSubmitValue_Click(object sender,  EventArgs e)
  6. {
  7.    this.matrixArr[i,j] = this.txtInput.Text;
  8.    j++;
  9.    if(j >= this.maxj)
  10.    {
  11.        j = 0;
  12.        i++;
  13.    }
  14.    if(i >= this.maxi)
  15.    {
  16.        //array has been filled if it reaches this line
  17.        this.txtInput.Enabled = false;
  18.        this.btnSubmit.Enabled = false;
  19.    }
  20. }
I have used an online converter to convert it to vb .net, but havent tested it

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer =  0,j As Integer =  0 
  2. Dim maxi As Integer =  2,maxj As Integer =  2 
  3. Dim matrixArr(,) As Integer =  New Integer(maxi,maxj) {} 
  4.  
  5. Private  Sub btnSubmitValue_Click(ByVal sender As Object, ByVal e As EventArgs)
  6.    Me.matrixArr(i,j) = Me.txtInput.Text
  7.    j = j + 1
  8.    If j >= Me.maxj Then
  9.        j = 0
  10.        i = i + 1
  11.    End If
  12.    If i >= Me.maxi Then
  13.        'array has been filled if it reaches this line
  14.        Me.txtInput.Enabled = False
  15.        Me.btnSubmit.Enabled = False
  16.    End If
  17. End Sub
Dec 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris Dunaway | last post by:
A quick scan of the group did not immediately reveal an answer to my questions so here goes. First let me describe my app and then I'll ask the...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that...
3
by: Tim Gallivan | last post by:
Hi all, I think read somewhere (but I can't find it ... note to self: must get new filing system ...) that there is a workaround so that an...
2
by: Dotnet Gruven | last post by:
Hi, If a server is physically localled in CST and is shared, how can one create a Web Application on that server that has its timezone for EST???...
10
by: Brett Romero | last post by:
I'd like to store something such as the following the my app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...
6
by: NickP | last post by:
Hi there, I am implementing a simple "/U" command line argument for a .NET application that instructs the application to delete the following...
8
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing...
3
by: =?Utf-8?B?Sm9u?= | last post by:
Hello, I have tried to use the app.config and settings.cs files to store my data (which I want to be user changeable at runtime). I can write to...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.